aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video
diff options
context:
space:
mode:
authorMike Isely <isely@pobox.com>2006-09-23 21:26:52 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2006-10-03 14:13:34 -0400
commit32ffa9ae03c529df4208b63b4b17c6d84141faa3 (patch)
tree55be825b8bb7d1dafdc2fe936d1e5df47d1a1fbe /drivers/media/video
parent59753950a67edf386413c7b18039b89de56b40fb (diff)
V4L/DVB (4662): Pvrusb2: Implement VIDIOC_INT_[G|S]_REGISTER
Implement VIDIOC_INT_SET_REGISTER and VIDIOC_INT_GET_REGISTER for the pvrusb2 driver. This is a debugging aid which will not be enabled unless CONFIG_VIDEO_ADV_DEBUG has been enabled. Signed-off-by: Mike Isely <isely@pobox.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video')
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c32
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h8
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c14
3 files changed, 54 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 88604365777c..11a327d167be 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -24,6 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/firmware.h> 25#include <linux/firmware.h>
26#include <linux/videodev2.h> 26#include <linux/videodev2.h>
27#include <media/v4l2-common.h>
27#include <asm/semaphore.h> 28#include <asm/semaphore.h>
28#include "pvrusb2.h" 29#include "pvrusb2.h"
29#include "pvrusb2-std.h" 30#include "pvrusb2-std.h"
@@ -3131,6 +3132,37 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
3131} 3132}
3132 3133
3133 3134
3135int pvr2_hdw_register_access(struct pvr2_hdw *hdw,
3136 u32 chip_id,unsigned long reg_id,
3137 int setFl,u32 *val_ptr)
3138{
3139#ifdef CONFIG_VIDEO_ADV_DEBUG
3140 struct list_head *item;
3141 struct pvr2_i2c_client *cp;
3142 struct v4l2_register req;
3143 int stat;
3144
3145 req.i2c_id = chip_id;
3146 req.reg = reg_id;
3147 if (setFl) req.val = *val_ptr;
3148 mutex_lock(&hdw->i2c_list_lock); do {
3149 list_for_each(item,&hdw->i2c_clients) {
3150 cp = list_entry(item,struct pvr2_i2c_client,list);
3151 if (cp->client->driver->id != chip_id) continue;
3152 stat = pvr2_i2c_client_cmd(
3153 cp,(setFl ? VIDIOC_INT_S_REGISTER :
3154 VIDIOC_INT_G_REGISTER),&req);
3155 if (!setFl) *val_ptr = req.val;
3156 return stat;
3157 }
3158 } while (0); mutex_unlock(&hdw->i2c_list_lock);
3159 return -EINVAL;
3160#else
3161 return -ENOSYS;
3162#endif
3163}
3164
3165
3134/* 3166/*
3135 Stuff for Emacs to see, in order to encourage consistent editing style: 3167 Stuff for Emacs to see, in order to encourage consistent editing style:
3136 *** Local Variables: *** 3168 *** Local Variables: ***
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index fd931b5da490..29979bb2a768 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -211,6 +211,14 @@ int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *);
211/* Store the v4l minor device number */ 211/* Store the v4l minor device number */
212void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int); 212void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int);
213 213
214/* Direct read/write access to chip's registers:
215 chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx)
216 reg_id - register number to access
217 setFl - true to set the register, false to read it
218 val_ptr - storage location for source / result. */
219int pvr2_hdw_register_access(struct pvr2_hdw *,
220 u32 chip_id,unsigned long reg_id,
221 int setFl,u32 *val_ptr);
214 222
215/* The following entry points are all lower level things you normally don't 223/* The following entry points are all lower level things you normally don't
216 want to worry about. */ 224 want to worry about. */
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 3608c2f81df9..156e375c93e9 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -671,6 +671,20 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
671 ret = 0; 671 ret = 0;
672 break; 672 break;
673 } 673 }
674#ifdef CONFIG_VIDEO_ADV_DEBUG
675 case VIDIOC_INT_G_REGISTER:
676 case VIDIOC_INT_S_REGISTER:
677 {
678 u32 val;
679 struct v4l2_register *req = (struct v4l2_register *)arg;
680 if (cmd == VIDIOC_INT_S_REGISTER) val = req->val;
681 ret = pvr2_hdw_register_access(
682 hdw,req->i2c_id,req->reg,
683 cmd == VIDIOC_INT_S_REGISTER,&val);
684 if (cmd == 0) req->val = val;
685 break;
686 }
687#endif
674 688
675 default : 689 default :
676 ret = v4l_compat_translate_ioctl(inode,file,cmd, 690 ret = v4l_compat_translate_ioctl(inode,file,cmd,