Skip to content

Commit

Permalink
V4L/DVB (10141): v4l2: debugging API changed to match against driver …
Browse files Browse the repository at this point in the history
…name instead of ID.

Since the i2c driver ID will be removed in the near future we have to
modify the v4l2 debugging API to use the driver name instead of driver ID.

Note that this API is not used in applications other than v4l2-dbg.cpp
as it is for debugging and testing only.

Should anyone use the old VIDIOC_G_CHIP_IDENT, then this will be logged
with a warning that it is deprecated and will be removed in 2.6.30.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Jan 2, 2009
1 parent da1b5c9 commit aecde8b
Show file tree
Hide file tree
Showing 52 changed files with 290 additions and 281 deletions.
2 changes: 1 addition & 1 deletion Documentation/video4linux/v4l2-framework.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ may be NULL if the subdev driver does not support anything from that category.
It looks like this:

struct v4l2_subdev_core_ops {
int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip);
int (*g_chip_ident)(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip);
int (*log_status)(struct v4l2_subdev *sd);
int (*init)(struct v4l2_subdev *sd, u32 val);
...
Expand Down
9 changes: 5 additions & 4 deletions drivers/media/video/bt8xx/bttv-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2039,34 +2039,35 @@ static int bttv_log_status(struct file *file, void *f)

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int bttv_g_register(struct file *file, void *f,
struct v4l2_register *reg)
struct v4l2_dbg_register *reg)
{
struct bttv_fh *fh = f;
struct bttv *btv = fh->btv;

if (!capable(CAP_SYS_ADMIN))
return -EPERM;

if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
if (!v4l2_chip_match_host(&reg->match))
return -EINVAL;

/* bt848 has a 12-bit register space */
reg->reg &= 0xfff;
reg->val = btread(reg->reg);
reg->size = 1;

return 0;
}

static int bttv_s_register(struct file *file, void *f,
struct v4l2_register *reg)
struct v4l2_dbg_register *reg)
{
struct bttv_fh *fh = f;
struct bttv *btv = fh->btv;

if (!capable(CAP_SYS_ADMIN))
return -EPERM;

if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
if (!v4l2_chip_match_host(&reg->match))
return -EINVAL;

/* bt848 has a 12-bit register space */
Expand Down
7 changes: 4 additions & 3 deletions drivers/media/video/cafe_ccic.c
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,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 };
struct v4l2_dbg_chip_ident chip;
int ret;

mutex_lock(&cam->s_mutex);
Expand All @@ -869,8 +869,9 @@ static int cafe_cam_init(struct cafe_camera *cam)
ret = __cafe_cam_reset(cam);
if (ret)
goto out;
chip.match_chip = cam->sensor->addr;
ret = __cafe_cam_cmd(cam, VIDIOC_G_CHIP_IDENT, &chip);
chip.match.type = V4L2_CHIP_MATCH_I2C_ADDR;
chip.match.addr = cam->sensor->addr;
ret = __cafe_cam_cmd(cam, VIDIOC_DBG_G_CHIP_IDENT, &chip);
if (ret)
goto out;
cam->sensor_type = chip.ident;
Expand Down
13 changes: 6 additions & 7 deletions drivers/media/video/cs5345.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,24 @@ static int cs5345_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
}

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int cs5345_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg)
static int cs5345_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

if (!v4l2_chip_match_i2c_client(client,
reg->match_type, reg->match_chip))
if (!v4l2_chip_match_i2c_client(client, &reg->match))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
reg->size = 1;
reg->val = cs5345_read(sd, reg->reg & 0x1f);
return 0;
}

static int cs5345_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg)
static int cs5345_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

if (!v4l2_chip_match_i2c_client(client,
reg->match_type, reg->match_chip))
if (!v4l2_chip_match_i2c_client(client, &reg->match))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
Expand All @@ -122,7 +121,7 @@ static int cs5345_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg)
}
#endif

static int cs5345_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip)
static int cs5345_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/cs53l32a.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static int cs53l32a_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
return 0;
}

static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip)
static int cs53l32a_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

Expand Down
28 changes: 1 addition & 27 deletions drivers/media/video/cx18/cx18-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg)
return retval;
}
}
if (cmd != VIDIOC_G_CHIP_IDENT)
if (cmd != VIDIOC_DBG_G_CHIP_IDENT)
CX18_ERR("i2c addr 0x%02x not found for cmd 0x%x!\n",
addr, cmd);
return -ENODEV;
Expand All @@ -268,17 +268,6 @@ static int cx18_i2c_id_addr(struct cx18 *cx, u32 id)
return retval;
}

/* Find the i2c device name matching the DRIVERID */
static const char *cx18_i2c_id_name(u32 id)
{
int i;

for (i = 0; i < ARRAY_SIZE(hw_driverids); i++)
if (hw_driverids[i] == id)
return hw_devicenames[i];
return "unknown device";
}

/* Find the i2c device name matching the CX18_HW_ flag */
static const char *cx18_i2c_hw_name(u32 hw)
{
Expand Down Expand Up @@ -326,21 +315,6 @@ int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg)
return cx18_call_i2c_client(cx, addr, cmd, arg);
}

/* Calls i2c device based on I2C driver ID. */
int cx18_i2c_id(struct cx18 *cx, u32 id, unsigned int cmd, void *arg)
{
int addr;

addr = cx18_i2c_id_addr(cx, id);
if (addr < 0) {
if (cmd != VIDIOC_G_CHIP_IDENT)
CX18_ERR("i2c ID 0x%08x (%s) not found for cmd 0x%x!\n",
id, cx18_i2c_id_name(id), cmd);
return addr;
}
return cx18_call_i2c_client(cx, addr, cmd, arg);
}

/* broadcast cmd for all I2C clients and for the gpio subsystem */
void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg)
{
Expand Down
1 change: 0 additions & 1 deletion drivers/media/video/cx18/cx18-i2c.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

int cx18_i2c_hw_addr(struct cx18 *cx, u32 hw);
int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg);
int cx18_i2c_id(struct cx18 *cx, u32 id, unsigned int cmd, void *arg);
int cx18_call_i2c_client(struct cx18 *cx, int addr, unsigned cmd, void *arg);
void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg);
int cx18_i2c_register(struct cx18 *cx, unsigned idx);
Expand Down
41 changes: 15 additions & 26 deletions drivers/media/video/cx18/cx18-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,30 +254,24 @@ static int cx18_s_fmt_sliced_vbi_cap(struct file *file, void *fh,
}

static int cx18_g_chip_ident(struct file *file, void *fh,
struct v4l2_chip_ident *chip)
struct v4l2_dbg_chip_ident *chip)
{
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;

chip->ident = V4L2_IDENT_NONE;
chip->revision = 0;
if (chip->match_type == V4L2_CHIP_MATCH_HOST) {
if (v4l2_chip_match_host(chip->match_type, chip->match_chip))
chip->ident = V4L2_IDENT_CX23418;
if (v4l2_chip_match_host(&chip->match)) {
chip->ident = V4L2_IDENT_CX23418;
return 0;
}
if (chip->match_type == V4L2_CHIP_MATCH_I2C_DRIVER)
return cx18_i2c_id(cx, chip->match_chip, VIDIOC_G_CHIP_IDENT,
chip);
if (chip->match_type == V4L2_CHIP_MATCH_I2C_ADDR)
return cx18_call_i2c_client(cx, chip->match_chip,
VIDIOC_G_CHIP_IDENT, chip);
return -EINVAL;
cx18_call_i2c_clients(cx, VIDIOC_DBG_G_CHIP_IDENT, chip);
return 0;
}

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
{
struct v4l2_register *regs = arg;
struct v4l2_dbg_register *regs = arg;
unsigned long flags;

if (!capable(CAP_SYS_ADMIN))
Expand All @@ -286,6 +280,7 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
return -EINVAL;

spin_lock_irqsave(&cx18_cards_lock, flags);
regs->size = 4;
if (cmd == VIDIOC_DBG_G_REGISTER)
regs->val = cx18_read_enc(cx, regs->reg);
else
Expand All @@ -295,31 +290,25 @@ static int cx18_cxc(struct cx18 *cx, unsigned int cmd, void *arg)
}

static int cx18_g_register(struct file *file, void *fh,
struct v4l2_register *reg)
struct v4l2_dbg_register *reg)
{
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;

if (v4l2_chip_match_host(reg->match_type, reg->match_chip))
if (v4l2_chip_match_host(&reg->match))
return cx18_cxc(cx, VIDIOC_DBG_G_REGISTER, reg);
if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER)
return cx18_i2c_id(cx, reg->match_chip, VIDIOC_DBG_G_REGISTER,
reg);
return cx18_call_i2c_client(cx, reg->match_chip, VIDIOC_DBG_G_REGISTER,
reg);
cx18_call_i2c_clients(cx, VIDIOC_DBG_G_REGISTER, reg);
return 0;
}

static int cx18_s_register(struct file *file, void *fh,
struct v4l2_register *reg)
struct v4l2_dbg_register *reg)
{
struct cx18 *cx = ((struct cx18_open_id *)fh)->cx;

if (v4l2_chip_match_host(reg->match_type, reg->match_chip))
if (v4l2_chip_match_host(&reg->match))
return cx18_cxc(cx, VIDIOC_DBG_S_REGISTER, reg);
if (reg->match_type == V4L2_CHIP_MATCH_I2C_DRIVER)
return cx18_i2c_id(cx, reg->match_chip, VIDIOC_DBG_S_REGISTER,
reg);
return cx18_call_i2c_client(cx, reg->match_chip, VIDIOC_DBG_S_REGISTER,
reg);
cx18_call_i2c_clients(cx, VIDIOC_DBG_S_REGISTER, reg);
return 0;
}
#endif

Expand Down
8 changes: 4 additions & 4 deletions drivers/media/video/cx23885/cx23885-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1326,11 +1326,11 @@ static int vidioc_s_frequency(struct file *file, void *priv,

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int vidioc_g_register(struct file *file, void *fh,
struct v4l2_register *reg)
struct v4l2_dbg_register *reg)
{
struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev;

if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
if (!v4l2_chip_match_host(&reg->match))
return -EINVAL;

cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_G_REGISTER, reg);
Expand All @@ -1339,11 +1339,11 @@ static int vidioc_g_register(struct file *file, void *fh,
}

static int vidioc_s_register(struct file *file, void *fh,
struct v4l2_register *reg)
struct v4l2_dbg_register *reg)
{
struct cx23885_dev *dev = ((struct cx23885_fh *)fh)->dev;

if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
if (!v4l2_chip_match_host(&reg->match))
return -EINVAL;

cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_DBG_S_REGISTER, reg);
Expand Down
13 changes: 6 additions & 7 deletions drivers/media/video/cx25840/cx25840-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,25 +1120,24 @@ static int cx25840_init(struct v4l2_subdev *sd, u32 val)
}

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int cx25840_g_register(struct v4l2_subdev *sd, struct v4l2_register *reg)
static int cx25840_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

if (!v4l2_chip_match_i2c_client(client,
reg->match_type, reg->match_chip))
if (!v4l2_chip_match_i2c_client(client, &reg->match))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
reg->size = 1;
reg->val = cx25840_read(client, reg->reg & 0x0fff);
return 0;
}

static int cx25840_s_register(struct v4l2_subdev *sd, struct v4l2_register *reg)
static int cx25840_s_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
{
struct i2c_client *client = v4l2_get_subdevdata(sd);

if (!v4l2_chip_match_i2c_client(client,
reg->match_type, reg->match_chip))
if (!v4l2_chip_match_i2c_client(client, &reg->match))
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
Expand Down Expand Up @@ -1362,7 +1361,7 @@ static int cx25840_reset(struct v4l2_subdev *sd, u32 val)
return 0;
}

static int cx25840_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_chip_ident *chip)
static int cx25840_g_chip_ident(struct v4l2_subdev *sd, struct v4l2_dbg_chip_ident *chip)
{
struct cx25840_state *state = to_state(sd);
struct i2c_client *client = v4l2_get_subdevdata(sd);
Expand Down
13 changes: 7 additions & 6 deletions drivers/media/video/cx88/cx88-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1447,25 +1447,26 @@ static int vidioc_s_frequency (struct file *file, void *priv,

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int vidioc_g_register (struct file *file, void *fh,
struct v4l2_register *reg)
struct v4l2_dbg_register *reg)
{
struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core;

if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
if (!v4l2_chip_match_host(&reg->match))
return -EINVAL;
/* cx2388x has a 24-bit register space */
reg->val = cx_read(reg->reg&0xffffff);
reg->val = cx_read(reg->reg & 0xffffff);
reg->size = 4;
return 0;
}

static int vidioc_s_register (struct file *file, void *fh,
struct v4l2_register *reg)
struct v4l2_dbg_register *reg)
{
struct cx88_core *core = ((struct cx8800_fh*)fh)->dev->core;

if (!v4l2_chip_match_host(reg->match_type, reg->match_chip))
if (!v4l2_chip_match_host(&reg->match))
return -EINVAL;
cx_write(reg->reg&0xffffff, reg->val);
cx_write(reg->reg & 0xffffff, reg->val);
return 0;
}
#endif
Expand Down
Loading

0 comments on commit aecde8b

Please sign in to comment.