diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2015-11-30 15:05:54 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-12-18 10:35:51 -0500 |
commit | fc279cc2887f0830b9232e970dd6a5dcd8612f3c (patch) | |
tree | a346fd8a28bff37433669cc5c71dac919dfb1795 | |
parent | bfd1bbfb54ac73175f5925ba32f14815315df30f (diff) |
[media] cs3308: add new 8-channel volume control driver
Add simple support for this 8 channel volume control driver.
Currently all it does is to unmute all 8 channels.
Based upon Devin's initial patch made for an older kernel which I
cleaned up and rebased. Thanks to Kernel Labs for that work.
Signed-off-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
-rw-r--r-- | MAINTAINERS | 9 | ||||
-rw-r--r-- | drivers/media/i2c/Kconfig | 10 | ||||
-rw-r--r-- | drivers/media/i2c/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/i2c/cs3308.c | 138 |
4 files changed, 158 insertions, 0 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index a04279769628..4635e1d14612 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -3094,6 +3094,15 @@ S: Maintained | |||
3094 | F: crypto/ansi_cprng.c | 3094 | F: crypto/ansi_cprng.c |
3095 | F: crypto/rng.c | 3095 | F: crypto/rng.c |
3096 | 3096 | ||
3097 | CS3308 MEDIA DRIVER | ||
3098 | M: Hans Verkuil <hverkuil@xs4all.nl> | ||
3099 | L: linux-media@vger.kernel.org | ||
3100 | T: git git://linuxtv.org/media_tree.git | ||
3101 | W: http://linuxtv.org | ||
3102 | S: Odd Fixes | ||
3103 | F: drivers/media/i2c/cs3308.c | ||
3104 | F: drivers/media/i2c/cs3308.h | ||
3105 | |||
3097 | CS5535 Audio ALSA driver | 3106 | CS5535 Audio ALSA driver |
3098 | M: Jaya Kumar <jayakumar.alsa@gmail.com> | 3107 | M: Jaya Kumar <jayakumar.alsa@gmail.com> |
3099 | S: Maintained | 3108 | S: Maintained |
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig index 521bbf1b29bc..993dc50c12db 100644 --- a/drivers/media/i2c/Kconfig +++ b/drivers/media/i2c/Kconfig | |||
@@ -83,6 +83,16 @@ config VIDEO_MSP3400 | |||
83 | To compile this driver as a module, choose M here: the | 83 | To compile this driver as a module, choose M here: the |
84 | module will be called msp3400. | 84 | module will be called msp3400. |
85 | 85 | ||
86 | config VIDEO_CS3308 | ||
87 | tristate "Cirrus Logic CS3308 audio ADC" | ||
88 | depends on VIDEO_V4L2 && I2C | ||
89 | ---help--- | ||
90 | Support for the Cirrus Logic CS3308 High Performance 8-Channel | ||
91 | Analog Volume Control | ||
92 | |||
93 | To compile this driver as a module, choose M here: the | ||
94 | module will be called cs3308. | ||
95 | |||
86 | config VIDEO_CS5345 | 96 | config VIDEO_CS5345 |
87 | tristate "Cirrus Logic CS5345 audio ADC" | 97 | tristate "Cirrus Logic CS5345 audio ADC" |
88 | depends on VIDEO_V4L2 && I2C | 98 | depends on VIDEO_V4L2 && I2C |
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile index 07db257abfc1..94f2c99e890d 100644 --- a/drivers/media/i2c/Makefile +++ b/drivers/media/i2c/Makefile | |||
@@ -43,6 +43,7 @@ obj-$(CONFIG_VIDEO_TVP7002) += tvp7002.o | |||
43 | obj-$(CONFIG_VIDEO_TW2804) += tw2804.o | 43 | obj-$(CONFIG_VIDEO_TW2804) += tw2804.o |
44 | obj-$(CONFIG_VIDEO_TW9903) += tw9903.o | 44 | obj-$(CONFIG_VIDEO_TW9903) += tw9903.o |
45 | obj-$(CONFIG_VIDEO_TW9906) += tw9906.o | 45 | obj-$(CONFIG_VIDEO_TW9906) += tw9906.o |
46 | obj-$(CONFIG_VIDEO_CS3308) += cs3308.o | ||
46 | obj-$(CONFIG_VIDEO_CS5345) += cs5345.o | 47 | obj-$(CONFIG_VIDEO_CS5345) += cs5345.o |
47 | obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o | 48 | obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o |
48 | obj-$(CONFIG_VIDEO_M52790) += m52790.o | 49 | obj-$(CONFIG_VIDEO_M52790) += m52790.o |
diff --git a/drivers/media/i2c/cs3308.c b/drivers/media/i2c/cs3308.c new file mode 100644 index 000000000000..d28b4f37fe5f --- /dev/null +++ b/drivers/media/i2c/cs3308.c | |||
@@ -0,0 +1,138 @@ | |||
1 | /* | ||
2 | * Cirrus Logic cs3308 8-Channel Analog Volume Control | ||
3 | * | ||
4 | * Copyright (C) 2010 Devin Heitmueller <dheitmueller@kernellabs.com> | ||
5 | * Copyright (C) 2012 Steven Toth <stoth@kernellabs.com> | ||
6 | * | ||
7 | * Derived from cs5345.c Copyright (C) 2007 Hans Verkuil | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify | ||
10 | * it under the terms of the GNU General Public License as published by | ||
11 | * the Free Software Foundation; either version 2 of the License, or | ||
12 | * (at your option) any later version. | ||
13 | * | ||
14 | * This program is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU General Public License for more details. | ||
18 | */ | ||
19 | |||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include <linux/kernel.h> | ||
23 | #include <linux/i2c.h> | ||
24 | #include <linux/slab.h> | ||
25 | #include <linux/videodev2.h> | ||
26 | #include <media/v4l2-device.h> | ||
27 | |||
28 | MODULE_DESCRIPTION("i2c device driver for cs3308 8-channel volume control"); | ||
29 | MODULE_AUTHOR("Devin Heitmueller"); | ||
30 | MODULE_LICENSE("GPL"); | ||
31 | |||
32 | static inline int cs3308_write(struct v4l2_subdev *sd, u8 reg, u8 value) | ||
33 | { | ||
34 | struct i2c_client *client = v4l2_get_subdevdata(sd); | ||
35 | |||
36 | return i2c_smbus_write_byte_data(client, reg, value); | ||
37 | } | ||
38 | |||
39 | static inline int cs3308_read(struct v4l2_subdev *sd, u8 reg) | ||
40 | { | ||
41 | struct i2c_client *client = v4l2_get_subdevdata(sd); | ||
42 | |||
43 | return i2c_smbus_read_byte_data(client, reg); | ||
44 | } | ||
45 | |||
46 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
47 | static int cs3308_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg) | ||
48 | { | ||
49 | reg->val = cs3308_read(sd, reg->reg & 0xffff); | ||
50 | reg->size = 1; | ||
51 | return 0; | ||
52 | } | ||
53 | |||
54 | static int cs3308_s_register(struct v4l2_subdev *sd, const struct v4l2_dbg_register *reg) | ||
55 | { | ||
56 | cs3308_write(sd, reg->reg & 0xffff, reg->val & 0xff); | ||
57 | return 0; | ||
58 | } | ||
59 | #endif | ||
60 | |||
61 | /* ----------------------------------------------------------------------- */ | ||
62 | |||
63 | static const struct v4l2_subdev_core_ops cs3308_core_ops = { | ||
64 | #ifdef CONFIG_VIDEO_ADV_DEBUG | ||
65 | .g_register = cs3308_g_register, | ||
66 | .s_register = cs3308_s_register, | ||
67 | #endif | ||
68 | }; | ||
69 | |||
70 | static const struct v4l2_subdev_ops cs3308_ops = { | ||
71 | .core = &cs3308_core_ops, | ||
72 | }; | ||
73 | |||
74 | /* ----------------------------------------------------------------------- */ | ||
75 | |||
76 | static int cs3308_probe(struct i2c_client *client, | ||
77 | const struct i2c_device_id *id) | ||
78 | { | ||
79 | struct v4l2_subdev *sd; | ||
80 | unsigned i; | ||
81 | |||
82 | /* Check if the adapter supports the needed features */ | ||
83 | if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) | ||
84 | return -EIO; | ||
85 | |||
86 | if ((i2c_smbus_read_byte_data(client, 0x1c) & 0xf0) != 0xe0) | ||
87 | return -ENODEV; | ||
88 | |||
89 | v4l_info(client, "chip found @ 0x%x (%s)\n", | ||
90 | client->addr << 1, client->adapter->name); | ||
91 | |||
92 | sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL); | ||
93 | if (sd == NULL) | ||
94 | return -ENOMEM; | ||
95 | |||
96 | v4l2_i2c_subdev_init(sd, client, &cs3308_ops); | ||
97 | |||
98 | /* Set some reasonable defaults */ | ||
99 | cs3308_write(sd, 0x0d, 0x00); /* Power up all channels */ | ||
100 | cs3308_write(sd, 0x0e, 0x00); /* Master Power */ | ||
101 | cs3308_write(sd, 0x0b, 0x00); /* Device Configuration */ | ||
102 | /* Set volume for each channel */ | ||
103 | for (i = 1; i <= 8; i++) | ||
104 | cs3308_write(sd, i, 0xd2); | ||
105 | cs3308_write(sd, 0x0a, 0x00); /* Unmute all channels */ | ||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | /* ----------------------------------------------------------------------- */ | ||
110 | |||
111 | static int cs3308_remove(struct i2c_client *client) | ||
112 | { | ||
113 | struct v4l2_subdev *sd = i2c_get_clientdata(client); | ||
114 | |||
115 | v4l2_device_unregister_subdev(sd); | ||
116 | kfree(sd); | ||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | /* ----------------------------------------------------------------------- */ | ||
121 | |||
122 | static const struct i2c_device_id cs3308_id[] = { | ||
123 | { "cs3308", 0 }, | ||
124 | { } | ||
125 | }; | ||
126 | MODULE_DEVICE_TABLE(i2c, cs3308_id); | ||
127 | |||
128 | static struct i2c_driver cs3308_driver = { | ||
129 | .driver = { | ||
130 | .owner = THIS_MODULE, | ||
131 | .name = "cs3308", | ||
132 | }, | ||
133 | .probe = cs3308_probe, | ||
134 | .remove = cs3308_remove, | ||
135 | .id_table = cs3308_id, | ||
136 | }; | ||
137 | |||
138 | module_i2c_driver(cs3308_driver); | ||