Skip to content

Commit

Permalink
[media] em28xx: add support for g_chip_name
Browse files Browse the repository at this point in the history
Add support for vidioc_g_chip_name, allowing AC97 to be implemented as a
second chip on the bridge with the name "ac97". v4l2-dbg can just match the
name with that string in order to detect a ac97-compliant set of registers.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Mar 25, 2013
1 parent c7622fc commit 3b2d17b
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions drivers/media/usb/em28xx/em28xx-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,9 +1245,9 @@ static int vidioc_g_chip_ident(struct file *file, void *priv,

chip->ident = V4L2_IDENT_NONE;
chip->revision = 0;
if (chip->match.type == V4L2_CHIP_MATCH_HOST) {
if (v4l2_chip_match_host(&chip->match))
chip->ident = V4L2_IDENT_NONE;
if (chip->match.type == V4L2_CHIP_MATCH_BRIDGE) {
if (chip->match.addr > 1)
return -EINVAL;
return 0;
}
if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER &&
Expand All @@ -1259,6 +1259,21 @@ static int vidioc_g_chip_ident(struct file *file, void *priv,
return 0;
}

static int vidioc_g_chip_name(struct file *file, void *priv,
struct v4l2_dbg_chip_name *chip)
{
struct em28xx_fh *fh = priv;
struct em28xx *dev = fh->dev;

if (chip->match.addr > 1)
return -EINVAL;
if (chip->match.addr == 1)
strlcpy(chip->name, "ac97", sizeof(chip->name));
else
strlcpy(chip->name, dev->v4l2_dev.name, sizeof(chip->name));
return 0;
}

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int em28xx_reg_len(int reg)
{
Expand All @@ -1280,6 +1295,12 @@ static int vidioc_g_register(struct file *file, void *priv,
int ret;

switch (reg->match.type) {
case V4L2_CHIP_MATCH_BRIDGE:
if (reg->match.addr > 1)
return -EINVAL;
if (!reg->match.addr)
break;
/* fall-through */
case V4L2_CHIP_MATCH_AC97:
ret = em28xx_read_ac97(dev, reg->reg);
if (ret < 0)
Expand All @@ -1296,8 +1317,7 @@ static int vidioc_g_register(struct file *file, void *priv,
v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_register, reg);
return 0;
default:
if (!v4l2_chip_match_host(&reg->match))
return -EINVAL;
return -EINVAL;
}

/* Match host */
Expand Down Expand Up @@ -1330,6 +1350,12 @@ static int vidioc_s_register(struct file *file, void *priv,
__le16 buf;

switch (reg->match.type) {
case V4L2_CHIP_MATCH_BRIDGE:
if (reg->match.addr > 1)
return -EINVAL;
if (!reg->match.addr)
break;
/* fall-through */
case V4L2_CHIP_MATCH_AC97:
return em28xx_write_ac97(dev, reg->reg, reg->val);
case V4L2_CHIP_MATCH_I2C_DRIVER:
Expand All @@ -1340,8 +1366,7 @@ static int vidioc_s_register(struct file *file, void *priv,
v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg);
return 0;
default:
if (!v4l2_chip_match_host(&reg->match))
return -EINVAL;
return -EINVAL;
}

/* Match host */
Expand Down Expand Up @@ -1699,6 +1724,7 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
.vidioc_g_chip_ident = vidioc_g_chip_ident,
.vidioc_g_chip_name = vidioc_g_chip_name,
#ifdef CONFIG_VIDEO_ADV_DEBUG
.vidioc_g_register = vidioc_g_register,
.vidioc_s_register = vidioc_s_register,
Expand Down Expand Up @@ -1729,6 +1755,7 @@ static const struct v4l2_ioctl_ops radio_ioctl_ops = {
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
.vidioc_g_chip_ident = vidioc_g_chip_ident,
.vidioc_g_chip_name = vidioc_g_chip_name,
#ifdef CONFIG_VIDEO_ADV_DEBUG
.vidioc_g_register = vidioc_g_register,
.vidioc_s_register = vidioc_s_register,
Expand Down

0 comments on commit 3b2d17b

Please sign in to comment.