Commit 3434eb7e authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (5306): Add support for VIDIOC_G_CHIP_IDENT



VIDIOC_G_CHIP_IDENT improves debugging of card problems: it can be
used to detect which chips are on the board and based on that information
selected register dumps can be made, making it easy to debug complicated
media chips containing tens or hundreds of registers.
This ioctl replaces the internal VIDIOC_INT_G_CHIP_IDENT ioctl.

Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@infradead.org>
parent ced80c67
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
#include <linux/spinlock.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include <media/v4l2-chip-ident.h>
#include <linux/device.h>
#include <linux/wait.h>
#include <linux/list.h>
@@ -164,7 +165,7 @@ struct cafe_camera
	struct tasklet_struct s_tasklet;

	/* Current operating parameters */
	enum v4l2_chip_ident sensor_type;		/* Currently ov7670 only */
	u32 sensor_type;		/* Currently ov7670 only */
	struct v4l2_pix_format pix_format;

	/* Locks */
@@ -818,6 +819,7 @@ static int __cafe_cam_reset(struct cafe_camera *cam)
 */
static int cafe_cam_init(struct cafe_camera *cam)
{
	struct v4l2_chip_ident chip = { V4L2_CHIP_MATCH_I2C_ADDR, 0, 0, 0 };
	int ret;

	mutex_lock(&cam->s_mutex);
@@ -827,9 +829,11 @@ static int cafe_cam_init(struct cafe_camera *cam)
	ret = __cafe_cam_reset(cam);
	if (ret)
		goto out;
	ret = __cafe_cam_cmd(cam, VIDIOC_INT_G_CHIP_IDENT, &cam->sensor_type);
	chip.match_chip = cam->sensor->addr;
	ret = __cafe_cam_cmd(cam, VIDIOC_G_CHIP_IDENT, &chip);
	if (ret)
		goto out;
	cam->sensor_type = chip.ident;
//	if (cam->sensor->addr != OV7xx0_SID) {
	if (cam->sensor_type != V4L2_IDENT_OV7670) {
		cam_err(cam, "Unsupported sensor type %d", cam->sensor->addr);
+5 −4
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <linux/videodev2.h>
#include <linux/i2c.h>
#include <media/v4l2-common.h>
#include <media/v4l2-chip-ident.h>
#include <media/cx25840.h>

#include "cx25840-core.h"
@@ -827,9 +828,8 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
			cx25840_initialize(client, 0);
		break;

	case VIDIOC_INT_G_CHIP_IDENT:
		*(enum v4l2_chip_ident *)arg = state->id;
		break;
	case VIDIOC_G_CHIP_IDENT:
		return v4l2_chip_ident_i2c_client(client, arg, state->id, state->rev);

	default:
		return -EINVAL;
@@ -847,7 +847,7 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
{
	struct i2c_client *client;
	struct cx25840_state *state;
	enum v4l2_chip_ident id;
	u32 id;
	u16 device_id;

	/* Check if the adapter supports the needed features
@@ -902,6 +902,7 @@ static int cx25840_detect_client(struct i2c_adapter *adapter, int address,
	state->audmode = V4L2_TUNER_MODE_LANG1;
	state->vbi_line_offset = 8;
	state->id = id;
	state->rev = device_id;

	i2c_attach_client(client);

+2 −1
Original line number Diff line number Diff line
@@ -43,7 +43,8 @@ struct cx25840_state {
	u32 audclk_freq;
	int audmode;
	int vbi_line_offset;
	enum v4l2_chip_ident id;
	u32 id;
	u32 rev;
	int is_cx25836;
};

+3 −3
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@
#include <linux/delay.h>
#include <linux/videodev.h>
#include <media/v4l2-common.h>
#include <media/v4l2-chip-ident.h>
#include <linux/i2c.h>


@@ -1270,9 +1271,8 @@ static int ov7670_command(struct i2c_client *client, unsigned int cmd,
		void *arg)
{
	switch (cmd) {
	case VIDIOC_INT_G_CHIP_IDENT:
		* (enum v4l2_chip_ident *) arg = V4L2_IDENT_OV7670;
		return 0;
	case VIDIOC_G_CHIP_IDENT:
		return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_OV7670, 0);

	case VIDIOC_INT_RESET:
		ov7670_reset(client);
+4 −5
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include <linux/i2c.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include <media/v4l2-chip-ident.h>
#include <media/saa7115.h>
#include <asm/div64.h>

@@ -80,7 +81,7 @@ struct saa711x_state {
	int sat;
	int width;
	int height;
	enum v4l2_chip_ident ident;
	u32 ident;
	u32 audclk_freq;
	u32 crystal_freq;
	u8 ucgc;
@@ -1232,7 +1233,6 @@ static void saa711x_decode_vbi_line(struct i2c_client *client,
static int saa711x_command(struct i2c_client *client, unsigned int cmd, void *arg)
{
	struct saa711x_state *state = i2c_get_clientdata(client);
	int *iarg = arg;

	/* ioctls to allow direct access to the saa7115 registers for testing */
	switch (cmd) {
@@ -1437,9 +1437,8 @@ static int saa711x_command(struct i2c_client *client, unsigned int cmd, void *ar
	}
#endif

	case VIDIOC_INT_G_CHIP_IDENT:
		*iarg = state->ident;
		break;
	case VIDIOC_G_CHIP_IDENT:
		return v4l2_chip_ident_i2c_client(client, arg, state->ident, 0);

	default:
		return -EINVAL;
Loading