summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-09-09 08:23:31 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 12:00:16 -0500
commit1b9e94dc69959e963fe57ede46259f792641af4d (patch)
treead4c224da8280c427076aff7d3e20914bf2be3ea
parent78dea1aed44a6e3e16973e584b00825359d470bd (diff)
[media] bttv: add VIDIOC_DBG_G_CHIP_IDENT
VIDIOC_DBG_G_CHIP_IDENT is a prerequisite for the G/S_REGISTER ioctls. In addition, add support to call G/S_REGISTER for supporting i2c devices. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c40
-rw-r--r--drivers/media/pci/bt8xx/bttv.h3
-rw-r--r--include/media/v4l2-chip-ident.h8
3 files changed, 47 insertions, 4 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index cc7f58f94cde..b36d67577535 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -49,6 +49,7 @@
49#include "bttvp.h" 49#include "bttvp.h"
50#include <media/v4l2-common.h> 50#include <media/v4l2-common.h>
51#include <media/v4l2-ioctl.h> 51#include <media/v4l2-ioctl.h>
52#include <media/v4l2-chip-ident.h>
52#include <media/tvaudio.h> 53#include <media/tvaudio.h>
53#include <media/msp3400.h> 54#include <media/msp3400.h>
54 55
@@ -2059,6 +2060,28 @@ static int bttv_log_status(struct file *file, void *f)
2059 return 0; 2060 return 0;
2060} 2061}
2061 2062
2063static int bttv_g_chip_ident(struct file *file, void *f, struct v4l2_dbg_chip_ident *chip)
2064{
2065 struct bttv_fh *fh = f;
2066 struct bttv *btv = fh->btv;
2067
2068 chip->ident = V4L2_IDENT_NONE;
2069 chip->revision = 0;
2070 if (chip->match.type == V4L2_CHIP_MATCH_HOST) {
2071 if (v4l2_chip_match_host(&chip->match)) {
2072 chip->ident = btv->id;
2073 if (chip->ident == PCI_DEVICE_ID_FUSION879)
2074 chip->ident = V4L2_IDENT_BT879;
2075 }
2076 return 0;
2077 }
2078 if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER &&
2079 chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
2080 return -EINVAL;
2081 /* TODO: is this correct? */
2082 return bttv_call_all_err(btv, core, g_chip_ident, chip);
2083}
2084
2062#ifdef CONFIG_VIDEO_ADV_DEBUG 2085#ifdef CONFIG_VIDEO_ADV_DEBUG
2063static int bttv_g_register(struct file *file, void *f, 2086static int bttv_g_register(struct file *file, void *f,
2064 struct v4l2_dbg_register *reg) 2087 struct v4l2_dbg_register *reg)
@@ -2069,8 +2092,12 @@ static int bttv_g_register(struct file *file, void *f,
2069 if (!capable(CAP_SYS_ADMIN)) 2092 if (!capable(CAP_SYS_ADMIN))
2070 return -EPERM; 2093 return -EPERM;
2071 2094
2072 if (!v4l2_chip_match_host(&reg->match)) 2095 if (!v4l2_chip_match_host(&reg->match)) {
2073 return -EINVAL; 2096 /* TODO: subdev errors should not be ignored, this should become a
2097 subdev helper function. */
2098 bttv_call_all(btv, core, g_register, reg);
2099 return 0;
2100 }
2074 2101
2075 /* bt848 has a 12-bit register space */ 2102 /* bt848 has a 12-bit register space */
2076 reg->reg &= 0xfff; 2103 reg->reg &= 0xfff;
@@ -2089,8 +2116,12 @@ static int bttv_s_register(struct file *file, void *f,
2089 if (!capable(CAP_SYS_ADMIN)) 2116 if (!capable(CAP_SYS_ADMIN))
2090 return -EPERM; 2117 return -EPERM;
2091 2118
2092 if (!v4l2_chip_match_host(&reg->match)) 2119 if (!v4l2_chip_match_host(&reg->match)) {
2093 return -EINVAL; 2120 /* TODO: subdev errors should not be ignored, this should become a
2121 subdev helper function. */
2122 bttv_call_all(btv, core, s_register, reg);
2123 return 0;
2124 }
2094 2125
2095 /* bt848 has a 12-bit register space */ 2126 /* bt848 has a 12-bit register space */
2096 reg->reg &= 0xfff; 2127 reg->reg &= 0xfff;
@@ -3394,6 +3425,7 @@ static const struct v4l2_ioctl_ops bttv_ioctl_ops = {
3394 .vidioc_s_frequency = bttv_s_frequency, 3425 .vidioc_s_frequency = bttv_s_frequency,
3395 .vidioc_log_status = bttv_log_status, 3426 .vidioc_log_status = bttv_log_status,
3396 .vidioc_querystd = bttv_querystd, 3427 .vidioc_querystd = bttv_querystd,
3428 .vidioc_g_chip_ident = bttv_g_chip_ident,
3397#ifdef CONFIG_VIDEO_ADV_DEBUG 3429#ifdef CONFIG_VIDEO_ADV_DEBUG
3398 .vidioc_g_register = bttv_g_register, 3430 .vidioc_g_register = bttv_g_register,
3399 .vidioc_s_register = bttv_s_register, 3431 .vidioc_s_register = bttv_s_register,
diff --git a/drivers/media/pci/bt8xx/bttv.h b/drivers/media/pci/bt8xx/bttv.h
index 79a11240a590..6139ce26dc2c 100644
--- a/drivers/media/pci/bt8xx/bttv.h
+++ b/drivers/media/pci/bt8xx/bttv.h
@@ -359,6 +359,9 @@ void bttv_gpio_bits(struct bttv_core *core, u32 mask, u32 bits);
359#define bttv_call_all(btv, o, f, args...) \ 359#define bttv_call_all(btv, o, f, args...) \
360 v4l2_device_call_all(&btv->c.v4l2_dev, 0, o, f, ##args) 360 v4l2_device_call_all(&btv->c.v4l2_dev, 0, o, f, ##args)
361 361
362#define bttv_call_all_err(btv, o, f, args...) \
363 v4l2_device_call_until_err(&btv->c.v4l2_dev, 0, o, f, ##args)
364
362extern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for); 365extern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for);
363extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1, 366extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
364 unsigned char b2, int both); 367 unsigned char b2, int both);
diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 4ee125bae719..b5996f959a31 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -96,12 +96,20 @@ enum {
96 /* module au0828 */ 96 /* module au0828 */
97 V4L2_IDENT_AU0828 = 828, 97 V4L2_IDENT_AU0828 = 828,
98 98
99 /* module bttv: ident 848 + 849 */
100 V4L2_IDENT_BT848 = 848,
101 V4L2_IDENT_BT849 = 849,
102
99 /* module bt856: just ident 856 */ 103 /* module bt856: just ident 856 */
100 V4L2_IDENT_BT856 = 856, 104 V4L2_IDENT_BT856 = 856,
101 105
102 /* module bt866: just ident 866 */ 106 /* module bt866: just ident 866 */
103 V4L2_IDENT_BT866 = 866, 107 V4L2_IDENT_BT866 = 866,
104 108
109 /* module bttv: ident 878 + 879 */
110 V4L2_IDENT_BT878 = 878,
111 V4L2_IDENT_BT879 = 879,
112
105 /* module ks0127: reserved range 1120-1129 */ 113 /* module ks0127: reserved range 1120-1129 */
106 V4L2_IDENT_KS0122S = 1122, 114 V4L2_IDENT_KS0122S = 1122,
107 V4L2_IDENT_KS0127 = 1127, 115 V4L2_IDENT_KS0127 = 1127,