aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/i2c
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-03-09 05:20:12 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-24 11:24:11 -0400
commit73d9f979335e9ae40f3901d38af739bc36d008c4 (patch)
treea137b1e6e825e4b28923494225dca8a244ba1a0d /drivers/media/i2c
parentec367c3cd18697991923685eb0e833f4424d37fb (diff)
[media] uda1342: add new uda1342 audio codec driver
This based on the wis-uda1342.c driver that's part of the go7007 driver. It has been converted to a v4l subdev driver by Pete Eberlein, and I made additional cleanups. Based on work by: Pete Eberlein <pete@sensoray.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r--drivers/media/i2c/Kconfig9
-rw-r--r--drivers/media/i2c/Makefile1
-rw-r--r--drivers/media/i2c/uda1342.c113
3 files changed, 123 insertions, 0 deletions
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 790788597bad..5df353f7c552 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -112,6 +112,15 @@ config VIDEO_TLV320AIC23B
112 To compile this driver as a module, choose M here: the 112 To compile this driver as a module, choose M here: the
113 module will be called tlv320aic23b. 113 module will be called tlv320aic23b.
114 114
115config VIDEO_UDA1342
116 tristate "Philips UDA1342 audio codec"
117 depends on VIDEO_V4L2 && I2C
118 ---help---
119 Support for the Philips UDA1342 audio codec.
120
121 To compile this driver as a module, choose M here: the
122 module will be called uda1342.
123
115config VIDEO_WM8775 124config VIDEO_WM8775
116 tristate "Wolfson Microelectronics WM8775 audio ADC with input mixer" 125 tristate "Wolfson Microelectronics WM8775 audio ADC with input mixer"
117 depends on VIDEO_V4L2 && I2C 126 depends on VIDEO_V4L2 && I2C
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index adf950406a94..b1775b3fad04 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -41,6 +41,7 @@ obj-$(CONFIG_VIDEO_CS5345) += cs5345.o
41obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o 41obj-$(CONFIG_VIDEO_CS53L32A) += cs53l32a.o
42obj-$(CONFIG_VIDEO_M52790) += m52790.o 42obj-$(CONFIG_VIDEO_M52790) += m52790.o
43obj-$(CONFIG_VIDEO_TLV320AIC23B) += tlv320aic23b.o 43obj-$(CONFIG_VIDEO_TLV320AIC23B) += tlv320aic23b.o
44obj-$(CONFIG_VIDEO_UDA1342) += uda1342.o
44obj-$(CONFIG_VIDEO_WM8775) += wm8775.o 45obj-$(CONFIG_VIDEO_WM8775) += wm8775.o
45obj-$(CONFIG_VIDEO_WM8739) += wm8739.o 46obj-$(CONFIG_VIDEO_WM8739) += wm8739.o
46obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o 47obj-$(CONFIG_VIDEO_VP27SMPX) += vp27smpx.o
diff --git a/drivers/media/i2c/uda1342.c b/drivers/media/i2c/uda1342.c
new file mode 100644
index 000000000000..3af408556d27
--- /dev/null
+++ b/drivers/media/i2c/uda1342.c
@@ -0,0 +1,113 @@
1/*
2 * Copyright (C) 2005-2006 Micronas USA Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License (Version 2) as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software Foundation,
15 * Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
16 */
17
18#include <linux/module.h>
19#include <linux/init.h>
20#include <linux/i2c.h>
21#include <linux/videodev2.h>
22#include <media/v4l2-device.h>
23#include <media/uda1342.h>
24#include <linux/slab.h>
25
26static int write_reg(struct i2c_client *client, int reg, int value)
27{
28 /* UDA1342 wants MSB first, but SMBus sends LSB first */
29 i2c_smbus_write_word_data(client, reg, swab16(value));
30 return 0;
31}
32
33static int uda1342_s_routing(struct v4l2_subdev *sd,
34 u32 input, u32 output, u32 config)
35{
36 struct i2c_client *client = v4l2_get_subdevdata(sd);
37
38 switch (input) {
39 case UDA1342_IN1:
40 write_reg(client, 0x00, 0x1241); /* select input 1 */
41 break;
42 case UDA1342_IN2:
43 write_reg(client, 0x00, 0x1441); /* select input 2 */
44 break;
45 default:
46 v4l2_err(sd, "input %d not supported\n", input);
47 break;
48 }
49 return 0;
50}
51
52static const struct v4l2_subdev_audio_ops uda1342_audio_ops = {
53 .s_routing = uda1342_s_routing,
54};
55
56static const struct v4l2_subdev_ops uda1342_ops = {
57 .audio = &uda1342_audio_ops,
58};
59
60static int uda1342_probe(struct i2c_client *client,
61 const struct i2c_device_id *id)
62{
63 struct i2c_adapter *adapter = client->adapter;
64 struct v4l2_subdev *sd;
65
66 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WORD_DATA))
67 return -ENODEV;
68
69 dev_dbg(&client->dev, "initializing UDA1342 at address %d on %s\n",
70 client->addr, adapter->name);
71
72 sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
73 if (sd == NULL)
74 return -ENOMEM;
75
76 v4l2_i2c_subdev_init(sd, client, &uda1342_ops);
77
78 write_reg(client, 0x00, 0x8000); /* reset registers */
79 write_reg(client, 0x00, 0x1241); /* select input 1 */
80
81 v4l_info(client, "chip found @ 0x%02x (%s)\n",
82 client->addr << 1, client->adapter->name);
83
84 return 0;
85}
86
87static int uda1342_remove(struct i2c_client *client)
88{
89 struct v4l2_subdev *sd = i2c_get_clientdata(client);
90
91 v4l2_device_unregister_subdev(sd);
92 kfree(sd);
93 return 0;
94}
95
96static const struct i2c_device_id uda1342_id[] = {
97 { "uda1342", 0 },
98 { }
99};
100MODULE_DEVICE_TABLE(i2c, uda1342_id);
101
102static struct i2c_driver uda1342_driver = {
103 .driver = {
104 .name = "uda1342",
105 },
106 .probe = uda1342_probe,
107 .remove = uda1342_remove,
108 .id_table = uda1342_id,
109};
110
111module_i2c_driver(uda1342_driver);
112
113MODULE_LICENSE("GPL v2");