Skip to content

Commit

Permalink
V4L/DVB (7160): em28xx: Allow register dump/setting for debug
Browse files Browse the repository at this point in the history
Adds vidioc_[g|s]_register handlers. This allows getting/setting register
from em28xx.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Mauro Carvalho Chehab committed Feb 18, 2008
1 parent 7463dda commit 1e7ad56
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions drivers/media/video/em28xx/em28xx-video.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,64 @@ static int vidioc_s_frequency(struct file *file, void *priv,
return 0;
}

#ifdef CONFIG_VIDEO_ADV_DEBUG
static int em28xx_reg_len(int reg)
{
switch (reg) {
case AC97LSB_REG:
case HSCALELOW_REG:
case VSCALELOW_REG:

return 2;
default:
return 1;
}
}

static int vidioc_g_register(struct file *file, void *priv,
struct v4l2_register *reg)
{
struct em28xx_fh *fh = priv;
struct em28xx *dev = fh->dev;
int ret;

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

if (em28xx_reg_len(reg->reg) == 1) {
ret = em28xx_read_reg(dev, reg->reg);
if (ret < 0)
return ret;

reg->val = ret;
} else {
u16 val;
ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS,
reg->reg, (char *)&val, 2);
if (ret < 0)
return ret;

reg->val = val;
}

return 0;
}

static int vidioc_s_register(struct file *file, void *priv,
struct v4l2_register *reg)
{
struct em28xx_fh *fh = priv;
struct em28xx *dev = fh->dev;
u16 buf;

buf = be16_to_cpu((__u16)reg->val);

return em28xx_write_regs(dev, reg->reg, (char *)&buf,
em28xx_reg_len(reg->reg));
}
#endif


static int vidioc_cropcap(struct file *file, void *priv,
struct v4l2_cropcap *cc)
{
Expand Down Expand Up @@ -1730,6 +1788,10 @@ static const struct video_device em28xx_video_template = {
.vidioc_s_tuner = vidioc_s_tuner,
.vidioc_g_frequency = vidioc_g_frequency,
.vidioc_s_frequency = vidioc_s_frequency,
#ifdef CONFIG_VIDEO_ADV_DEBUG
.vidioc_g_register = vidioc_g_register,
.vidioc_s_register = vidioc_s_register,
#endif

.tvnorms = V4L2_STD_ALL,
.current_norm = V4L2_STD_PAL,
Expand All @@ -1752,6 +1814,10 @@ static struct video_device em28xx_radio_template = {
.vidioc_s_ctrl = vidioc_s_ctrl,
.vidioc_g_frequency = vidioc_g_frequency,
.vidioc_s_frequency = vidioc_s_frequency,
#ifdef CONFIG_VIDEO_ADV_DEBUG
.vidioc_g_register = vidioc_g_register,
.vidioc_s_register = vidioc_s_register,
#endif
};

/******************************** usb interface *****************************************/
Expand Down

0 comments on commit 1e7ad56

Please sign in to comment.