aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2007-01-23 20:38:13 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2007-02-21 10:34:55 -0500
commit52ebc763d8e0c9f2ab48af89a75e90e2318bac86 (patch)
tree5699ff9425fb1da30a18b00661fcea659ace6a72 /drivers
parentdbbff48f39263f7e5c96a55624da87879de2bf71 (diff)
V4L/DVB (5146): Make VIDIOC_INT_[SG]_REGISTER ioctls no longer internal only
The direct register access ioctls were defined as kernel internal only, but they are very useful for debugging hardware from userspace and are used as such. Officially export them. VIDIOC_INT_[SG]_REGISTER is renamed to VIDIOC_DBG_[SG]_REGISTER Definition of ioctl and struct v4l2_register is moved from v4l2-common.h to videodev2.h. Types used in struct v4l2_register are changed to the userspace exportable versions (u32 -> __u32, etc). Use of VIDIOC_DBG_S_REGISTER requires CAP_SYS_ADMIN permission, so move the check into the video_ioctl2() dispatcher so it doesn't need to be duplicated in each driver's call-back function. CAP_SYS_ADMIN check is added to pvrusb2 (which doesn't use video_ioctl2). Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/cx25840/cx25840-core.c4
-rw-r--r--drivers/media/video/cx88/cx88-video.c2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.c6
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-hdw.h2
-rw-r--r--drivers/media/video/pvrusb2/pvrusb2-v4l2.c14
-rw-r--r--drivers/media/video/saa7115.c4
-rw-r--r--drivers/media/video/saa7127.c4
-rw-r--r--drivers/media/video/tvp5150.c4
-rw-r--r--drivers/media/video/upd64031a.c4
-rw-r--r--drivers/media/video/upd64083.c4
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c12
-rw-r--r--drivers/media/video/v4l2-common.c11
-rw-r--r--drivers/media/video/videodev.c8
13 files changed, 42 insertions, 37 deletions
diff --git a/drivers/media/video/cx25840/cx25840-core.c b/drivers/media/video/cx25840/cx25840-core.c
index 7bb7589a07c3..6515b2a78417 100644
--- a/drivers/media/video/cx25840/cx25840-core.c
+++ b/drivers/media/video/cx25840/cx25840-core.c
@@ -628,7 +628,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
628#ifdef CONFIG_VIDEO_ADV_DEBUG 628#ifdef CONFIG_VIDEO_ADV_DEBUG
629 /* ioctls to allow direct access to the 629 /* ioctls to allow direct access to the
630 * cx25840 registers for testing */ 630 * cx25840 registers for testing */
631 case VIDIOC_INT_G_REGISTER: 631 case VIDIOC_DBG_G_REGISTER:
632 { 632 {
633 struct v4l2_register *reg = arg; 633 struct v4l2_register *reg = arg;
634 634
@@ -638,7 +638,7 @@ static int cx25840_command(struct i2c_client *client, unsigned int cmd,
638 break; 638 break;
639 } 639 }
640 640
641 case VIDIOC_INT_S_REGISTER: 641 case VIDIOC_DBG_S_REGISTER:
642 { 642 {
643 struct v4l2_register *reg = arg; 643 struct v4l2_register *reg = arg;
644 644
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c
index ee8cbd33cfc1..f6736eb786bc 100644
--- a/drivers/media/video/cx88/cx88-video.c
+++ b/drivers/media/video/cx88/cx88-video.c
@@ -1405,8 +1405,6 @@ static int vidioc_s_register (struct file *file, void *fh,
1405 1405
1406 if (reg->i2c_id != 0) 1406 if (reg->i2c_id != 0)
1407 return -EINVAL; 1407 return -EINVAL;
1408 if (!capable(CAP_SYS_ADMIN))
1409 return -EPERM;
1410 cx_write(reg->reg&0xffffff, reg->val); 1408 cx_write(reg->reg&0xffffff, reg->val);
1411 return 0; 1409 return 0;
1412} 1410}
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.c b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
index 5e166ed19fc5..2a350755bd30 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.c
@@ -3277,7 +3277,7 @@ static int pvr2_hdw_get_eeprom_addr(struct pvr2_hdw *hdw)
3277 3277
3278 3278
3279int pvr2_hdw_register_access(struct pvr2_hdw *hdw, 3279int pvr2_hdw_register_access(struct pvr2_hdw *hdw,
3280 u32 chip_id,unsigned long reg_id, 3280 u32 chip_id, u32 reg_id,
3281 int setFl,u32 *val_ptr) 3281 int setFl,u32 *val_ptr)
3282{ 3282{
3283#ifdef CONFIG_VIDEO_ADV_DEBUG 3283#ifdef CONFIG_VIDEO_ADV_DEBUG
@@ -3295,8 +3295,8 @@ int pvr2_hdw_register_access(struct pvr2_hdw *hdw,
3295 cp = list_entry(item,struct pvr2_i2c_client,list); 3295 cp = list_entry(item,struct pvr2_i2c_client,list);
3296 if (cp->client->driver->id != chip_id) continue; 3296 if (cp->client->driver->id != chip_id) continue;
3297 stat = pvr2_i2c_client_cmd( 3297 stat = pvr2_i2c_client_cmd(
3298 cp,(setFl ? VIDIOC_INT_S_REGISTER : 3298 cp,(setFl ? VIDIOC_DBG_S_REGISTER :
3299 VIDIOC_INT_G_REGISTER),&req); 3299 VIDIOC_DBG_G_REGISTER),&req);
3300 if (!setFl) *val_ptr = req.val; 3300 if (!setFl) *val_ptr = req.val;
3301 okFl = !0; 3301 okFl = !0;
3302 break; 3302 break;
diff --git a/drivers/media/video/pvrusb2/pvrusb2-hdw.h b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
index dc7a3ba8dd18..e6df8e4a7fe0 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-hdw.h
+++ b/drivers/media/video/pvrusb2/pvrusb2-hdw.h
@@ -222,7 +222,7 @@ void pvr2_hdw_v4l_store_minor_number(struct pvr2_hdw *,
222 setFl - true to set the register, false to read it 222 setFl - true to set the register, false to read it
223 val_ptr - storage location for source / result. */ 223 val_ptr - storage location for source / result. */
224int pvr2_hdw_register_access(struct pvr2_hdw *, 224int pvr2_hdw_register_access(struct pvr2_hdw *,
225 u32 chip_id,unsigned long reg_id, 225 u32 chip_id,u32 reg_id,
226 int setFl,u32 *val_ptr); 226 int setFl,u32 *val_ptr);
227 227
228/* The following entry points are all lower level things you normally don't 228/* The following entry points are all lower level things you normally don't
diff --git a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
index 49f5d3c3614c..cde5f5f3e8f2 100644
--- a/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
+++ b/drivers/media/video/pvrusb2/pvrusb2-v4l2.c
@@ -738,16 +738,20 @@ static int pvr2_v4l2_do_ioctl(struct inode *inode, struct file *file,
738 break; 738 break;
739 } 739 }
740#ifdef CONFIG_VIDEO_ADV_DEBUG 740#ifdef CONFIG_VIDEO_ADV_DEBUG
741 case VIDIOC_INT_G_REGISTER: 741 case VIDIOC_DBG_S_REGISTER:
742 case VIDIOC_INT_S_REGISTER: 742 if (!capable(CAP_SYS_ADMIN)) {
743 ret = -EPERM;
744 break;
745 } /* fall through */
746 case VIDIOC_DBG_G_REGISTER:
743 { 747 {
744 u32 val; 748 u32 val;
745 struct v4l2_register *req = (struct v4l2_register *)arg; 749 struct v4l2_register *req = (struct v4l2_register *)arg;
746 if (cmd == VIDIOC_INT_S_REGISTER) val = req->val; 750 if (cmd == VIDIOC_DBG_S_REGISTER) val = req->val;
747 ret = pvr2_hdw_register_access( 751 ret = pvr2_hdw_register_access(
748 hdw,req->i2c_id,req->reg, 752 hdw,req->i2c_id,req->reg,
749 cmd == VIDIOC_INT_S_REGISTER,&val); 753 cmd == VIDIOC_DBG_S_REGISTER,&val);
750 if (cmd == VIDIOC_INT_G_REGISTER) req->val = val; 754 if (cmd == VIDIOC_DBG_G_REGISTER) req->val = val;
751 break; 755 break;
752 } 756 }
753#endif 757#endif
diff --git a/drivers/media/video/saa7115.c b/drivers/media/video/saa7115.c
index 389e518bc3e5..bb6aa135002a 100644
--- a/drivers/media/video/saa7115.c
+++ b/drivers/media/video/saa7115.c
@@ -1417,7 +1417,7 @@ static int saa711x_command(struct i2c_client *client, unsigned int cmd, void *ar
1417 } 1417 }
1418 1418
1419#ifdef CONFIG_VIDEO_ADV_DEBUG 1419#ifdef CONFIG_VIDEO_ADV_DEBUG
1420 case VIDIOC_INT_G_REGISTER: 1420 case VIDIOC_DBG_G_REGISTER:
1421 { 1421 {
1422 struct v4l2_register *reg = arg; 1422 struct v4l2_register *reg = arg;
1423 1423
@@ -1427,7 +1427,7 @@ static int saa711x_command(struct i2c_client *client, unsigned int cmd, void *ar
1427 break; 1427 break;
1428 } 1428 }
1429 1429
1430 case VIDIOC_INT_S_REGISTER: 1430 case VIDIOC_DBG_S_REGISTER:
1431 { 1431 {
1432 struct v4l2_register *reg = arg; 1432 struct v4l2_register *reg = arg;
1433 1433
diff --git a/drivers/media/video/saa7127.c b/drivers/media/video/saa7127.c
index ad401bdefeaf..304375ade4a9 100644
--- a/drivers/media/video/saa7127.c
+++ b/drivers/media/video/saa7127.c
@@ -614,7 +614,7 @@ static int saa7127_command(struct i2c_client *client,
614 break; 614 break;
615 615
616#ifdef CONFIG_VIDEO_ADV_DEBUG 616#ifdef CONFIG_VIDEO_ADV_DEBUG
617 case VIDIOC_INT_G_REGISTER: 617 case VIDIOC_DBG_G_REGISTER:
618 { 618 {
619 struct v4l2_register *reg = arg; 619 struct v4l2_register *reg = arg;
620 620
@@ -624,7 +624,7 @@ static int saa7127_command(struct i2c_client *client,
624 break; 624 break;
625 } 625 }
626 626
627 case VIDIOC_INT_S_REGISTER: 627 case VIDIOC_DBG_S_REGISTER:
628 { 628 {
629 struct v4l2_register *reg = arg; 629 struct v4l2_register *reg = arg;
630 630
diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index bc0a4fc27b24..65d4389690a0 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -950,7 +950,7 @@ static int tvp5150_command(struct i2c_client *c,
950 } 950 }
951 951
952#ifdef CONFIG_VIDEO_ADV_DEBUG 952#ifdef CONFIG_VIDEO_ADV_DEBUG
953 case VIDIOC_INT_G_REGISTER: 953 case VIDIOC_DBG_G_REGISTER:
954 { 954 {
955 struct v4l2_register *reg = arg; 955 struct v4l2_register *reg = arg;
956 956
@@ -960,7 +960,7 @@ static int tvp5150_command(struct i2c_client *c,
960 break; 960 break;
961 } 961 }
962 962
963 case VIDIOC_INT_S_REGISTER: 963 case VIDIOC_DBG_S_REGISTER:
964 { 964 {
965 struct v4l2_register *reg = arg; 965 struct v4l2_register *reg = arg;
966 966
diff --git a/drivers/media/video/upd64031a.c b/drivers/media/video/upd64031a.c
index fc52201d607e..0eee82ba52bc 100644
--- a/drivers/media/video/upd64031a.c
+++ b/drivers/media/video/upd64031a.c
@@ -162,7 +162,7 @@ static int upd64031a_command(struct i2c_client *client, unsigned int cmd, void *
162 break; 162 break;
163 163
164#ifdef CONFIG_VIDEO_ADV_DEBUG 164#ifdef CONFIG_VIDEO_ADV_DEBUG
165 case VIDIOC_INT_G_REGISTER: 165 case VIDIOC_DBG_G_REGISTER:
166 { 166 {
167 struct v4l2_register *reg = arg; 167 struct v4l2_register *reg = arg;
168 168
@@ -172,7 +172,7 @@ static int upd64031a_command(struct i2c_client *client, unsigned int cmd, void *
172 break; 172 break;
173 } 173 }
174 174
175 case VIDIOC_INT_S_REGISTER: 175 case VIDIOC_DBG_S_REGISTER:
176 { 176 {
177 struct v4l2_register *reg = arg; 177 struct v4l2_register *reg = arg;
178 u8 addr = reg->reg & 0xff; 178 u8 addr = reg->reg & 0xff;
diff --git a/drivers/media/video/upd64083.c b/drivers/media/video/upd64083.c
index c3a7ffe5c267..3f0eec0cdb45 100644
--- a/drivers/media/video/upd64083.c
+++ b/drivers/media/video/upd64083.c
@@ -139,7 +139,7 @@ static int upd64083_command(struct i2c_client *client, unsigned int cmd, void *a
139 break; 139 break;
140 140
141#ifdef CONFIG_VIDEO_ADV_DEBUG 141#ifdef CONFIG_VIDEO_ADV_DEBUG
142 case VIDIOC_INT_G_REGISTER: 142 case VIDIOC_DBG_G_REGISTER:
143 { 143 {
144 struct v4l2_register *reg = arg; 144 struct v4l2_register *reg = arg;
145 145
@@ -149,7 +149,7 @@ static int upd64083_command(struct i2c_client *client, unsigned int cmd, void *a
149 break; 149 break;
150 } 150 }
151 151
152 case VIDIOC_INT_S_REGISTER: 152 case VIDIOC_DBG_S_REGISTER:
153 { 153 {
154 struct v4l2_register *reg = arg; 154 struct v4l2_register *reg = arg;
155 u8 addr = reg->reg & 0xff; 155 u8 addr = reg->reg & 0xff;
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c
index 82c39767ba34..b6fabeeb8ab8 100644
--- a/drivers/media/video/usbvision/usbvision-video.c
+++ b/drivers/media/video/usbvision/usbvision-video.c
@@ -519,7 +519,7 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
519 519
520#ifdef CONFIG_VIDEO_ADV_DEBUG 520#ifdef CONFIG_VIDEO_ADV_DEBUG
521 /* ioctls to allow direct acces to the NT100x registers */ 521 /* ioctls to allow direct acces to the NT100x registers */
522 case VIDIOC_INT_G_REGISTER: 522 case VIDIOC_DBG_G_REGISTER:
523 { 523 {
524 struct v4l2_register *reg = arg; 524 struct v4l2_register *reg = arg;
525 int errCode; 525 int errCode;
@@ -529,17 +529,17 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
529 /* NT100x has a 8-bit register space */ 529 /* NT100x has a 8-bit register space */
530 errCode = usbvision_read_reg(usbvision, reg->reg&0xff); 530 errCode = usbvision_read_reg(usbvision, reg->reg&0xff);
531 if (errCode < 0) { 531 if (errCode < 0) {
532 err("%s: VIDIOC_INT_G_REGISTER failed: error %d", __FUNCTION__, errCode); 532 err("%s: VIDIOC_DBG_G_REGISTER failed: error %d", __FUNCTION__, errCode);
533 } 533 }
534 else { 534 else {
535 reg->val=(unsigned char)errCode; 535 reg->val=(unsigned char)errCode;
536 PDEBUG(DBG_IOCTL, "VIDIOC_INT_G_REGISTER reg=0x%02X, value=0x%02X", 536 PDEBUG(DBG_IOCTL, "VIDIOC_DBG_G_REGISTER reg=0x%02X, value=0x%02X",
537 (unsigned int)reg->reg, reg->val); 537 (unsigned int)reg->reg, reg->val);
538 errCode = 0; // No error 538 errCode = 0; // No error
539 } 539 }
540 return errCode; 540 return errCode;
541 } 541 }
542 case VIDIOC_INT_S_REGISTER: 542 case VIDIOC_DBG_S_REGISTER:
543 { 543 {
544 struct v4l2_register *reg = arg; 544 struct v4l2_register *reg = arg;
545 int errCode; 545 int errCode;
@@ -550,10 +550,10 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file,
550 return -EPERM; 550 return -EPERM;
551 errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val); 551 errCode = usbvision_write_reg(usbvision, reg->reg&0xff, reg->val);
552 if (errCode < 0) { 552 if (errCode < 0) {
553 err("%s: VIDIOC_INT_S_REGISTER failed: error %d", __FUNCTION__, errCode); 553 err("%s: VIDIOC_DBG_S_REGISTER failed: error %d", __FUNCTION__, errCode);
554 } 554 }
555 else { 555 else {
556 PDEBUG(DBG_IOCTL, "VIDIOC_INT_S_REGISTER reg=0x%02X, value=0x%02X", 556 PDEBUG(DBG_IOCTL, "VIDIOC_DBG_S_REGISTER reg=0x%02X, value=0x%02X",
557 (unsigned int)reg->reg, reg->val); 557 (unsigned int)reg->reg, reg->val);
558 errCode = 0; 558 errCode = 0;
559 } 559 }
diff --git a/drivers/media/video/v4l2-common.c b/drivers/media/video/v4l2-common.c
index dab87512b9bd..d20d4ca5d8a3 100644
--- a/drivers/media/video/v4l2-common.c
+++ b/drivers/media/video/v4l2-common.c
@@ -400,9 +400,10 @@ static const char *v4l2_int_ioctls[] = {
400 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY", 400 [_IOC_NR(TUNER_SET_STANDBY)] = "TUNER_SET_STANDBY",
401 [_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG", 401 [_IOC_NR(TDA9887_SET_CONFIG)] = "TDA9887_SET_CONFIG",
402 402
403 [_IOC_NR(VIDIOC_DBG_S_REGISTER)] = "VIDIOC_DBG_S_REGISTER",
404 [_IOC_NR(VIDIOC_DBG_G_REGISTER)] = "VIDIOC_DBG_G_REGISTER",
405
403 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE", 406 [_IOC_NR(VIDIOC_INT_S_TUNER_MODE)] = "VIDIOC_INT_S_TUNER_MODE",
404 [_IOC_NR(VIDIOC_INT_S_REGISTER)] = "VIDIOC_INT_S_REGISTER",
405 [_IOC_NR(VIDIOC_INT_G_REGISTER)] = "VIDIOC_INT_G_REGISTER",
406 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET", 407 [_IOC_NR(VIDIOC_INT_RESET)] = "VIDIOC_INT_RESET",
407 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ", 408 [_IOC_NR(VIDIOC_INT_AUDIO_CLOCK_FREQ)] = "VIDIOC_INT_AUDIO_CLOCK_FREQ",
408 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE", 409 [_IOC_NR(VIDIOC_INT_DECODE_VBI_LINE)] = "VIDIOC_INT_DECODE_VBI_LINE",
@@ -753,11 +754,11 @@ void v4l_printk_ioctl_arg(char *s,unsigned int cmd, void *arg)
753 p->id,p->index,p->name); 754 p->id,p->index,p->name);
754 break; 755 break;
755 } 756 }
756 case VIDIOC_INT_G_REGISTER: 757 case VIDIOC_DBG_G_REGISTER:
757 case VIDIOC_INT_S_REGISTER: 758 case VIDIOC_DBG_S_REGISTER:
758 { 759 {
759 struct v4l2_register *p=arg; 760 struct v4l2_register *p=arg;
760 printk ("%s: i2c_id=%d, reg=%lu, val=%d\n", s, 761 printk ("%s: i2c_id=%d, reg=%d, val=%d\n", s,
761 p->i2c_id,p->reg,p->val); 762 p->i2c_id,p->reg,p->val);
762 763
763 break; 764 break;
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c
index 4b5d5f771e4c..764a53b70db2 100644
--- a/drivers/media/video/videodev.c
+++ b/drivers/media/video/videodev.c
@@ -1454,17 +1454,19 @@ static int __video_do_ioctl(struct inode *inode, struct file *file,
1454 break; 1454 break;
1455 } 1455 }
1456#ifdef CONFIG_VIDEO_ADV_DEBUG 1456#ifdef CONFIG_VIDEO_ADV_DEBUG
1457 case VIDIOC_INT_G_REGISTER: 1457 case VIDIOC_DBG_G_REGISTER:
1458 { 1458 {
1459 struct v4l2_register *p=arg; 1459 struct v4l2_register *p=arg;
1460 if (vfd->vidioc_g_register) 1460 if (vfd->vidioc_g_register)
1461 ret=vfd->vidioc_g_register(file, fh, p); 1461 ret=vfd->vidioc_g_register(file, fh, p);
1462 break; 1462 break;
1463 } 1463 }
1464 case VIDIOC_INT_S_REGISTER: 1464 case VIDIOC_DBG_S_REGISTER:
1465 { 1465 {
1466 struct v4l2_register *p=arg; 1466 struct v4l2_register *p=arg;
1467 if (vfd->vidioc_s_register) 1467 if (!capable(CAP_SYS_ADMIN))
1468 ret=-EPERM;
1469 else if (vfd->vidioc_s_register)
1468 ret=vfd->vidioc_s_register(file, fh, p); 1470 ret=vfd->vidioc_s_register(file, fh, p);
1469 break; 1471 break;
1470 } 1472 }