aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/wm8775.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/wm8775.c')
-rw-r--r--drivers/media/video/wm8775.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index bbfd55cd9948..c2e6d2e9f5f1 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -25,7 +25,6 @@
25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 */ 26 */
27 27
28
29#include <linux/module.h> 28#include <linux/module.h>
30#include <linux/types.h> 29#include <linux/types.h>
31#include <linux/ioctl.h> 30#include <linux/ioctl.h>
@@ -33,20 +32,12 @@
33#include <linux/i2c.h> 32#include <linux/i2c.h>
34#include <linux/i2c-id.h> 33#include <linux/i2c-id.h>
35#include <linux/videodev.h> 34#include <linux/videodev.h>
36#include <media/audiochip.h> 35#include <media/v4l2-common.h>
37 36
38MODULE_DESCRIPTION("wm8775 driver"); 37MODULE_DESCRIPTION("wm8775 driver");
39MODULE_AUTHOR("Ulf Eklund, Hans Verkuil"); 38MODULE_AUTHOR("Ulf Eklund, Hans Verkuil");
40MODULE_LICENSE("GPL"); 39MODULE_LICENSE("GPL");
41 40
42#define wm8775_err(fmt, arg...) do { \
43 printk(KERN_ERR "%s %d-%04x: " fmt, client->driver->driver.name, \
44 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
45#define wm8775_info(fmt, arg...) do { \
46 printk(KERN_INFO "%s %d-%04x: " fmt, client->driver->driver.name, \
47 i2c_adapter_id(client->adapter), client->addr , ## arg); } while (0)
48
49
50static unsigned short normal_i2c[] = { 0x36 >> 1, I2C_CLIENT_END }; 41static unsigned short normal_i2c[] = { 0x36 >> 1, I2C_CLIENT_END };
51 42
52 43
@@ -70,7 +61,7 @@ static int wm8775_write(struct i2c_client *client, int reg, u16 val)
70 int i; 61 int i;
71 62
72 if (reg < 0 || reg >= TOT_REGS) { 63 if (reg < 0 || reg >= TOT_REGS) {
73 wm8775_err("Invalid register R%d\n", reg); 64 v4l_err(client, "Invalid register R%d\n", reg);
74 return -1; 65 return -1;
75 } 66 }
76 67
@@ -80,7 +71,7 @@ static int wm8775_write(struct i2c_client *client, int reg, u16 val)
80 return 0; 71 return 0;
81 } 72 }
82 } 73 }
83 wm8775_err("I2C: cannot write %03x to register R%d\n", val, reg); 74 v4l_err(client, "I2C: cannot write %03x to register R%d\n", val, reg);
84 return -1; 75 return -1;
85} 76}
86 77
@@ -88,38 +79,53 @@ static int wm8775_command(struct i2c_client *client, unsigned int cmd,
88 void *arg) 79 void *arg)
89{ 80{
90 struct wm8775_state *state = i2c_get_clientdata(client); 81 struct wm8775_state *state = i2c_get_clientdata(client);
91 int *input = arg; 82 struct v4l2_audio *input = arg;
83 struct v4l2_control *ctrl = arg;
92 84
93 switch (cmd) { 85 switch (cmd) {
94 case AUDC_SET_INPUT: 86 case VIDIOC_S_AUDIO:
87 /* There are 4 inputs and one output. Zero or more inputs
88 are multiplexed together to the output. Hence there are
89 16 combinations.
90 If only one input is active (the normal case) then the
91 input values 1, 2, 4 or 8 should be used. */
92 if (input->index > 15) {
93 v4l_err(client, "Invalid input %d.\n", input->index);
94 return -EINVAL;
95 }
96 state->input = input->index;
97 if (state->muted)
98 break;
95 wm8775_write(client, R21, 0x0c0); 99 wm8775_write(client, R21, 0x0c0);
96 wm8775_write(client, R14, 0x1d4); 100 wm8775_write(client, R14, 0x1d4);
97 wm8775_write(client, R15, 0x1d4); 101 wm8775_write(client, R15, 0x1d4);
102 wm8775_write(client, R21, 0x100 + state->input);
103 break;
98 104
99 if (*input == AUDIO_RADIO) { 105 case VIDIOC_G_AUDIO:
100 wm8775_write(client, R21, 0x108); 106 memset(input, 0, sizeof(*input));
101 state->input = 8; 107 input->index = state->input;
102 state->muted = 0; 108 break;
103 break; 109
104 } 110 case VIDIOC_G_CTRL:
105 if (*input == AUDIO_MUTE) { 111 if (ctrl->id != V4L2_CID_AUDIO_MUTE)
106 state->muted = 1; 112 return -EINVAL;
107 break; 113 ctrl->value = state->muted;
108 } 114 break;
109 if (*input == AUDIO_UNMUTE) { 115
116 case VIDIOC_S_CTRL:
117 if (ctrl->id != V4L2_CID_AUDIO_MUTE)
118 return -EINVAL;
119 state->muted = ctrl->value;
120 wm8775_write(client, R21, 0x0c0);
121 wm8775_write(client, R14, 0x1d4);
122 wm8775_write(client, R15, 0x1d4);
123 if (!state->muted)
110 wm8775_write(client, R21, 0x100 + state->input); 124 wm8775_write(client, R21, 0x100 + state->input);
111 state->muted = 0;
112 break;
113 }
114 /* All other inputs... */
115 wm8775_write(client, R21, 0x102);
116 state->input = 2;
117 state->muted = 0;
118 break; 125 break;
119 126
120 case VIDIOC_LOG_STATUS: 127 case VIDIOC_LOG_STATUS:
121 wm8775_info("Input: %s%s\n", 128 v4l_info(client, "Input: %d%s\n", state->input,
122 state->input == 8 ? "radio" : "default",
123 state->muted ? " (muted)" : ""); 129 state->muted ? " (muted)" : "");
124 break; 130 break;
125 131
@@ -170,7 +176,7 @@ static int wm8775_attach(struct i2c_adapter *adapter, int address, int kind)
170 client->driver = &i2c_driver; 176 client->driver = &i2c_driver;
171 snprintf(client->name, sizeof(client->name) - 1, "wm8775"); 177 snprintf(client->name, sizeof(client->name) - 1, "wm8775");
172 178
173 wm8775_info("chip found @ 0x%x (%s)\n", address << 1, adapter->name); 179 v4l_info(client, "chip found @ 0x%x (%s)\n", address << 1, adapter->name);
174 180
175 state = kmalloc(sizeof(struct wm8775_state), GFP_KERNEL); 181 state = kmalloc(sizeof(struct wm8775_state), GFP_KERNEL);
176 if (state == NULL) { 182 if (state == NULL) {
@@ -206,11 +212,7 @@ static int wm8775_attach(struct i2c_adapter *adapter, int address, int kind)
206 212
207static int wm8775_probe(struct i2c_adapter *adapter) 213static int wm8775_probe(struct i2c_adapter *adapter)
208{ 214{
209#ifdef I2C_CLASS_TV_ANALOG
210 if (adapter->class & I2C_CLASS_TV_ANALOG) 215 if (adapter->class & I2C_CLASS_TV_ANALOG)
211#else
212 if (adapter->id == I2C_HW_B_BT848)
213#endif
214 return i2c_probe(adapter, &addr_data, wm8775_attach); 216 return i2c_probe(adapter, &addr_data, wm8775_attach);
215 return 0; 217 return 0;
216} 218}
@@ -235,12 +237,10 @@ static struct i2c_driver i2c_driver = {
235 .driver = { 237 .driver = {
236 .name = "wm8775", 238 .name = "wm8775",
237 }, 239 },
238 240 .id = I2C_DRIVERID_WM8775,
239 .id = I2C_DRIVERID_WM8775,
240
241 .attach_adapter = wm8775_probe, 241 .attach_adapter = wm8775_probe,
242 .detach_client = wm8775_detach, 242 .detach_client = wm8775_detach,
243 .command = wm8775_command, 243 .command = wm8775_command,
244}; 244};
245 245
246 246