aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/video/wm8775.c66
1 files changed, 38 insertions, 28 deletions
diff --git a/drivers/media/video/wm8775.c b/drivers/media/video/wm8775.c
index c31a0c34b08b..869f9e7946b6 100644
--- a/drivers/media/video/wm8775.c
+++ b/drivers/media/video/wm8775.c
@@ -68,17 +68,15 @@ static int wm8775_write(struct i2c_client *client, int reg, u16 val)
68 return -1; 68 return -1;
69 } 69 }
70 70
71 for (i = 0; i < 3; i++) { 71 for (i = 0; i < 3; i++)
72 if (i2c_smbus_write_byte_data(client, (reg << 1) | 72 if (i2c_smbus_write_byte_data(client,
73 (val >> 8), val & 0xff) == 0) { 73 (reg << 1) | (val >> 8), val & 0xff) == 0)
74 return 0; 74 return 0;
75 }
76 }
77 v4l_err(client, "I2C: cannot write %03x to register R%d\n", val, reg); 75 v4l_err(client, "I2C: cannot write %03x to register R%d\n", val, reg);
78 return -1; 76 return -1;
79} 77}
80 78
81static int wm8775_command(struct i2c_client *client, unsigned int cmd, void *arg) 79static int wm8775_command(struct i2c_client *client, unsigned cmd, void *arg)
82{ 80{
83 struct wm8775_state *state = i2c_get_clientdata(client); 81 struct wm8775_state *state = i2c_get_clientdata(client);
84 struct v4l2_routing *route = arg; 82 struct v4l2_routing *route = arg;
@@ -127,7 +125,8 @@ static int wm8775_command(struct i2c_client *client, unsigned int cmd, void *arg
127 break; 125 break;
128 126
129 case VIDIOC_G_CHIP_IDENT: 127 case VIDIOC_G_CHIP_IDENT:
130 return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_WM8775, 0); 128 return v4l2_chip_ident_i2c_client(client,
129 arg, V4L2_IDENT_WM8775, 0);
131 130
132 case VIDIOC_LOG_STATUS: 131 case VIDIOC_LOG_STATUS:
133 v4l_info(client, "Input: %d%s\n", state->input, 132 v4l_info(client, "Input: %d%s\n", state->input,
@@ -168,34 +167,45 @@ static int wm8775_probe(struct i2c_client *client)
168 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 167 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
169 return -EIO; 168 return -EIO;
170 169
171 v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); 170 v4l_info(client, "chip found @ 0x%x (%s)\n",
171 client->addr << 1, client->adapter->name);
172 172
173 state = kmalloc(sizeof(struct wm8775_state), GFP_KERNEL); 173 state = kmalloc(sizeof(struct wm8775_state), GFP_KERNEL);
174 if (state == NULL) { 174 if (state == NULL)
175 return -ENOMEM; 175 return -ENOMEM;
176 }
177 state->input = 2; 176 state->input = 2;
178 state->muted = 0; 177 state->muted = 0;
179 i2c_set_clientdata(client, state); 178 i2c_set_clientdata(client, state);
180 179
181 /* initialize wm8775 */ 180 /* Initialize wm8775 */
182 wm8775_write(client, R23, 0x000); /* RESET */ 181
183 wm8775_write(client, R7, 0x000); /* Disable zero cross detect timeout */ 182 /* RESET */
184 wm8775_write(client, R11, 0x021); /* Left justified, 24-bit mode */ 183 wm8775_write(client, R23, 0x000);
185 wm8775_write(client, R12, 0x102); /* Master mode, clock ratio 256fs */ 184 /* Disable zero cross detect timeout */
186 wm8775_write(client, R13, 0x000); /* Powered up */ 185 wm8775_write(client, R7, 0x000);
187 wm8775_write(client, R14, 0x1d4); /* ADC gain +2.5dB, enable zero cross */ 186 /* Left justified, 24-bit mode */
188 wm8775_write(client, R15, 0x1d4); /* ADC gain +2.5dB, enable zero cross */ 187 wm8775_write(client, R11, 0x021);
189 wm8775_write(client, R16, 0x1bf); /* ALC Stereo, ALC target level -1dB FS */ 188 /* Master mode, clock ratio 256fs */
190 /* max gain +8dB */ 189 wm8775_write(client, R12, 0x102);
191 wm8775_write(client, R17, 0x185); /* Enable gain control, use zero cross */ 190 /* Powered up */
192 /* detection, ALC hold time 42.6 ms */ 191 wm8775_write(client, R13, 0x000);
193 wm8775_write(client, R18, 0x0a2); /* ALC gain ramp up delay 34 s, */ 192 /* ADC gain +2.5dB, enable zero cross */
194 /* ALC gain ramp down delay 33 ms */ 193 wm8775_write(client, R14, 0x1d4);
195 wm8775_write(client, R19, 0x005); /* Enable noise gate, threshold -72dBfs */ 194 /* ADC gain +2.5dB, enable zero cross */
196 wm8775_write(client, R20, 0x07a); /* Transient window 4ms, lower PGA gain */ 195 wm8775_write(client, R15, 0x1d4);
197 /* limit -1dB */ 196 /* ALC Stereo, ALC target level -1dB FS max gain +8dB */
198 wm8775_write(client, R21, 0x102); /* LRBOTH = 1, use input 2. */ 197 wm8775_write(client, R16, 0x1bf);
198 /* Enable gain control, use zero cross detection,
199 ALC hold time 42.6 ms */
200 wm8775_write(client, R17, 0x185);
201 /* ALC gain ramp up delay 34 s, ALC gain ramp down delay 33 ms */
202 wm8775_write(client, R18, 0x0a2);
203 /* Enable noise gate, threshold -72dBfs */
204 wm8775_write(client, R19, 0x005);
205 /* Transient window 4ms, lower PGA gain limit -1dB */
206 wm8775_write(client, R20, 0x07a);
207 /* LRBOTH = 1, use input 2. */
208 wm8775_write(client, R21, 0x102);
199 return 0; 209 return 0;
200} 210}
201 211