提交 1e7ad56f 编写于 作者: M Mauro Carvalho Chehab

V4L/DVB (7160): em28xx: Allow register dump/setting for debug

Adds vidioc_[g|s]_register handlers. This allows getting/setting register
from em28xx.
Signed-off-by: NMauro Carvalho Chehab <mchehab@infradead.org>
上级 7463dda2
......@@ -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)
{
......@@ -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,
......@@ -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 *****************************************/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册