Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 38252
b: refs/heads/master
c: 32ffa9a
h: refs/heads/master
v: v3
  • Loading branch information
Mike Isely authored and Mauro Carvalho Chehab committed Oct 3, 2006
1 parent 964f2af commit 05b3ab3
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 59753950a67edf386413c7b18039b89de56b40fb
refs/heads/master: 32ffa9ae03c529df4208b63b4b17c6d84141faa3
32 changes: 32 additions & 0 deletions trunk/drivers/media/video/pvrusb2/pvrusb2-hdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/slab.h>
#include <linux/firmware.h>
#include <linux/videodev2.h>
#include <media/v4l2-common.h>
#include <asm/semaphore.h>
#include "pvrusb2.h"
#include "pvrusb2-std.h"
Expand Down Expand Up @@ -3131,6 +3132,37 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
}


int pvr2_hdw_register_access(struct pvr2_hdw *hdw,
u32 chip_id,unsigned long reg_id,
int setFl,u32 *val_ptr)
{
#ifdef CONFIG_VIDEO_ADV_DEBUG
struct list_head *item;
struct pvr2_i2c_client *cp;
struct v4l2_register req;
int stat;

req.i2c_id = chip_id;
req.reg = reg_id;
if (setFl) req.val = *val_ptr;
mutex_lock(&hdw->i2c_list_lock); do {
list_for_each(item,&hdw->i2c_clients) {
cp = list_entry(item,struct pvr2_i2c_client,list);
if (cp->client->driver->id != chip_id) continue;
stat = pvr2_i2c_client_cmd(
cp,(setFl ? VIDIOC_INT_S_REGISTER :
VIDIOC_INT_G_REGISTER),&req);
if (!setFl) *val_ptr = req.val;
return stat;
}
} while (0); mutex_unlock(&hdw->i2c_list_lock);
return -EINVAL;
#else
return -ENOSYS;
#endif
}


/*
Stuff for Emacs to see, in order to encourage consistent editing style:
*** Local Variables: ***
Expand Down
8 changes: 8 additions & 0 deletions trunk/drivers/media/video/pvrusb2/pvrusb2-hdw.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,14 @@ int pvr2_hdw_v4l_get_minor_number(struct pvr2_hdw *);
/* Store the v4l minor device number */
void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,int);

/* Direct read/write access to chip's registers:
chip_id - unique id of chip (e.g. I2C_DRIVERD_xxxx)
reg_id - register number to access
setFl - true to set the register, false to read it
val_ptr - storage location for source / result. */
int pvr2_hdw_register_access(struct pvr2_hdw *,
u32 chip_id,unsigned long reg_id,
int setFl,u32 *val_ptr);

/* The following entry points are all lower level things you normally don't
want to worry about. */
Expand Down
14 changes: 14 additions & 0 deletions trunk/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,20 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
ret = 0;
break;
}
#ifdef CONFIG_VIDEO_ADV_DEBUG
case VIDIOC_INT_G_REGISTER:
case VIDIOC_INT_S_REGISTER:
{
u32 val;
struct v4l2_register *req = (struct v4l2_register *)arg;
if (cmd == VIDIOC_INT_S_REGISTER) val = req->val;
ret = pvr2_hdw_register_access(
hdw,req->i2c_id,req->reg,
cmd == VIDIOC_INT_S_REGISTER,&val);
if (cmd == 0) req->val = val;
break;
}
#endif

default :
ret = v4l_compat_translate_ioctl(inode,file,cmd,
Expand Down

0 comments on commit 05b3ab3

Please sign in to comment.