mirror of
https://github.com/adulau/aha.git
synced 2025-01-04 07:03:38 +00:00
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: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
parent
7463dda2ae
commit
1e7ad56f1f
1 changed files with 66 additions and 0 deletions
|
@ -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 *****************************************/
|
||||
|
|
Loading…
Reference in a new issue