diff options
author | Chaithrika U S <chaithrika@ti.com> | 2009-05-07 08:29:25 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 17:20:59 -0400 |
commit | 40199c50b891d24d1a8f1d480f886680a3ac9b74 (patch) | |
tree | e15f48d7c3904faffdddd38817b84d0930972902 /drivers/media/video | |
parent | b475f4eeda1da16e995b2302f6eebdfb08ce18cd (diff) |
V4L/DVB (11742): TI THS7303 video amplifier driver code
This patch adds driver for TI THS7303 video amplifier. This driver is
implemented as a v4l2 sub device. Tested on TI DM646x EVM.
This version has updates based on review comments by Mauro Chehab.
Signed-off-by: Chaithrika U S <chaithrika@ti.com>
Reviewed-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video')
-rw-r--r-- | drivers/media/video/Kconfig | 9 | ||||
-rw-r--r-- | drivers/media/video/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/video/ths7303.c | 151 |
3 files changed, 161 insertions, 0 deletions
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig index 57835f5715fc..3308462a8354 100644 --- a/drivers/media/video/Kconfig +++ b/drivers/media/video/Kconfig | |||
@@ -440,6 +440,15 @@ config VIDEO_ADV7175 | |||
440 | To compile this driver as a module, choose M here: the | 440 | To compile this driver as a module, choose M here: the |
441 | module will be called adv7175. | 441 | module will be called adv7175. |
442 | 442 | ||
443 | config VIDEO_THS7303 | ||
444 | tristate "THS7303 Video Amplifier" | ||
445 | depends on I2C | ||
446 | help | ||
447 | Support for TI THS7303 video amplifier | ||
448 | |||
449 | To compile this driver as a module, choose M here: the | ||
450 | module will be called ths7303. | ||
451 | |||
443 | comment "Video improvement chips" | 452 | comment "Video improvement chips" |
444 | 453 | ||
445 | config VIDEO_UPD64031A | 454 | config VIDEO_UPD64031A |
diff --git a/drivers/media/video/Makefile b/drivers/media/video/Makefile index 7aefac64330f..352dd6d32000 100644 --- a/drivers/media/video/Makefile +++ b/drivers/media/video/Makefile | |||
@@ -54,6 +54,7 @@ obj-$(CONFIG_VIDEO_BT819) += bt819.o | |||
54 | obj-$(CONFIG_VIDEO_BT856) += bt856.o | 54 | obj-$(CONFIG_VIDEO_BT856) += bt856.o |
55 | obj-$(CONFIG_VIDEO_BT866) += bt866.o | 55 | obj-$(CONFIG_VIDEO_BT866) += bt866.o |
56 | obj-$(CONFIG_VIDEO_KS0127) += ks0127.o | 56 | obj-$(CONFIG_VIDEO_KS0127) += ks0127.o |
57 | obj-$(CONFIG_VIDEO_THS7303) += ths7303.o | ||
57 | 58 | ||
58 | obj-$(CONFIG_VIDEO_ZORAN) += zoran/ | 59 | obj-$(CONFIG_VIDEO_ZORAN) += zoran/ |
59 | 60 | ||
diff --git a/drivers/media/video/ths7303.c b/drivers/media/video/ths7303.c new file mode 100644 index 000000000000..21781f8a0e8e --- /dev/null +++ b/drivers/media/video/ths7303.c | |||
@@ -0,0 +1,151 @@ | |||
1 | /* | ||
2 | * ths7303- THS7303 Video Amplifier driver | ||
3 | * | ||
4 | * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License as | ||
8 | * published by the Free Software Foundation version 2. | ||
9 | * | ||
10 | * This program is distributed .as is. WITHOUT ANY WARRANTY of any | ||
11 | * kind, whether express or implied; without even the implied warranty | ||
12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | */ | ||
15 | |||
16 | #include <linux/kernel.h> | ||
17 | #include <linux/init.h> | ||
18 | #include <linux/ctype.h> | ||
19 | #include <linux/i2c.h> | ||
20 | #include <linux/device.h> | ||
21 | #include <linux/delay.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/uaccess.h> | ||
24 | #include <linux/videodev2.h> | ||
25 | |||
26 | #include <media/v4l2-device.h> | ||
27 | #include <media/v4l2-subdev.h> | ||
28 | #include <media/v4l2-chip-ident.h> | ||
29 | |||
30 | MODULE_DESCRIPTION("TI THS7303 video amplifier driver"); | ||
31 | MODULE_AUTHOR("Chaithrika U S"); | ||
32 | MODULE_LICENSE("GPL"); | ||
33 | |||
34 | static int debug; | ||
35 | module_param(debug, int, 0644); | ||
36 | MODULE_PARM_DESC(debug, "Debug level 0-1"); | ||
37 | |||
38 | /* following function is used to set ths7303 */ | ||
39 | static int ths7303_setvalue(struct v4l2_subdev *sd, v4l2_std_id std) | ||
40 | { | ||
41 | int err = 0; | ||
42 | u8 val; | ||
43 | struct i2c_client *client; | ||
44 | |||
45 | client = v4l2_get_subdevdata(sd); | ||
46 | |||
47 | if (std & (V4L2_STD_ALL & ~V4L2_STD_SECAM)) { | ||
48 | val = 0x02; | ||
49 | v4l2_dbg(1, debug, sd, "setting value for SDTV format\n"); | ||
50 | } else { | ||
51 | val = 0x00; | ||
52 | v4l2_dbg(1, debug, sd, "disabling all channels\n"); | ||
53 | } | ||
54 | |||
55 | err |= i2c_smbus_write_byte_data(client, 0x01, val); | ||
56 | err |= i2c_smbus_write_byte_data(client, 0x02, val); | ||
57 | err |= i2c_smbus_write_byte_data(client, 0x03, val); | ||
58 | |||
59 | if (err) | ||
60 | v4l2_err(sd, "write failed\n"); | ||
61 | |||
62 | return err; | ||
63 | } | ||
64 | |||
65 | static int ths7303_s_std_output(struct v4l2_subdev *sd, v4l2_std_id norm) | ||
66 | { | ||
67 | return ths7303_setvalue(sd, norm); | ||
68 | } | ||
69 | |||
70 | static int ths7303_g_chip_ident(struct v4l2_subdev *sd, | ||
71 | struct v4l2_dbg_chip_ident *chip) | ||
72 | { | ||
73 | struct i2c_client *client = v4l2_get_subdevdata(sd); | ||
74 | |||
75 | return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_THS7303, 0); | ||
76 | } | ||
77 | |||
78 | static const struct v4l2_subdev_video_ops ths7303_video_ops = { | ||
79 | .s_std_output = ths7303_s_std_output, | ||
80 | }; | ||
81 | |||
82 | static const struct v4l2_subdev_core_ops ths7303_core_ops = { | ||
83 | .g_chip_ident = ths7303_g_chip_ident, | ||
84 | }; | ||
85 | |||
86 | static const struct v4l2_subdev_ops ths7303_ops = { | ||
87 | .core = &ths7303_core_ops, | ||
88 | .video = &ths7303_video_ops, | ||
89 | }; | ||
90 | |||
91 | static int ths7303_probe(struct i2c_client *client, | ||
92 | const struct i2c_device_id *id) | ||
93 | { | ||
94 | struct v4l2_subdev *sd; | ||
95 | v4l2_std_id std_id = V4L2_STD_NTSC; | ||
96 | |||
97 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
98 | return -ENODEV; | ||
99 | |||
100 | v4l_info(client, "chip found @ 0x%x (%s)\n", | ||
101 | client->addr << 1, client->adapter->name); | ||
102 | |||
103 | sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | ||
104 | if (sd == NULL) | ||
105 | return -ENOMEM; | ||
106 | |||
107 | v4l2_i2c_subdev_init(sd, client, &ths7303_ops); | ||
108 | |||
109 | return ths7303_setvalue(sd, std_id); | ||
110 | } | ||
111 | |||
112 | static int ths7303_remove(struct i2c_client *client) | ||
113 | { | ||
114 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | ||
115 | |||
116 | v4l2_device_unregister_subdev(sd); | ||
117 | kfree(sd); | ||
118 | |||
119 | return 0; | ||
120 | } | ||
121 | |||
122 | static const struct i2c_device_id ths7303_id[] = { | ||
123 | {"ths7303", 0}, | ||
124 | {}, | ||
125 | }; | ||
126 | |||
127 | MODULE_DEVICE_TABLE(i2c, ths7303_id); | ||
128 | |||
129 | static struct i2c_driver ths7303_driver = { | ||
130 | .driver = { | ||
131 | .owner = THIS_MODULE, | ||
132 | .name = "ths7303", | ||
133 | }, | ||
134 | .probe = ths7303_probe, | ||
135 | .remove = ths7303_remove, | ||
136 | .id_table = ths7303_id, | ||
137 | }; | ||
138 | |||
139 | static int __init ths7303_init(void) | ||
140 | { | ||
141 | return i2c_add_driver(&ths7303_driver); | ||
142 | } | ||
143 | |||
144 | static void __exit ths7303_exit(void) | ||
145 | { | ||
146 | i2c_del_driver(&ths7303_driver); | ||
147 | } | ||
148 | |||
149 | module_init(ths7303_init); | ||
150 | module_exit(ths7303_exit); | ||
151 | |||