aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-11-01 06:45:54 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:03:16 -0500
commit099b8e7361512ebfef2dd51f2e81126cc93c22e9 (patch)
treeab2958a2ff31c34ed40cd49d5814fe52a83261d6
parent842441d42de8f22d8f530b19da984df81fed8f7e (diff)
V4L/DVB (6738): wm8739: codingstyle cleanups
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/video/wm8739.c65
1 files changed, 38 insertions, 27 deletions
diff --git a/drivers/media/video/wm8739.c b/drivers/media/video/wm8739.c
index 3d9e709833c5..ac4fee1d0251 100644
--- a/drivers/media/video/wm8739.c
+++ b/drivers/media/video/wm8739.c
@@ -36,7 +36,7 @@ MODULE_DESCRIPTION("wm8739 driver");
36MODULE_AUTHOR("T. Adachi, Hans Verkuil"); 36MODULE_AUTHOR("T. Adachi, Hans Verkuil");
37MODULE_LICENSE("GPL"); 37MODULE_LICENSE("GPL");
38 38
39static int debug = 0; 39static int debug;
40static unsigned short normal_i2c[] = { 0x34 >> 1, 0x36 >> 1, I2C_CLIENT_END }; 40static unsigned short normal_i2c[] = { 0x34 >> 1, 0x36 >> 1, I2C_CLIENT_END };
41 41
42module_param(debug, int, 0644); 42module_param(debug, int, 0644);
@@ -76,12 +76,10 @@ static int wm8739_write(struct i2c_client *client, int reg, u16 val)
76 76
77 v4l_dbg(1, debug, client, "write: %02x %02x\n", reg, val); 77 v4l_dbg(1, debug, client, "write: %02x %02x\n", reg, val);
78 78
79 for (i = 0; i < 3; i++) { 79 for (i = 0; i < 3; i++)
80 if (i2c_smbus_write_byte_data(client, (reg << 1) | 80 if (i2c_smbus_write_byte_data(client,
81 (val >> 8), val & 0xff) == 0) { 81 (reg << 1) | (val >> 8), val & 0xff) == 0)
82 return 0; 82 return 0;
83 }
84 }
85 v4l_err(client, "I2C: cannot write %03x to register R%d\n", val, reg); 83 v4l_err(client, "I2C: cannot write %03x to register R%d\n", val, reg);
86 return -1; 84 return -1;
87} 85}
@@ -168,7 +166,7 @@ static struct v4l2_queryctrl wm8739_qctrl[] = {
168 .default_value = 58880, 166 .default_value = 58880,
169 .flags = 0, 167 .flags = 0,
170 .type = V4L2_CTRL_TYPE_INTEGER, 168 .type = V4L2_CTRL_TYPE_INTEGER,
171 },{ 169 }, {
172 .id = V4L2_CID_AUDIO_MUTE, 170 .id = V4L2_CID_AUDIO_MUTE,
173 .name = "Mute", 171 .name = "Mute",
174 .minimum = 0, 172 .minimum = 0,
@@ -177,7 +175,7 @@ static struct v4l2_queryctrl wm8739_qctrl[] = {
177 .default_value = 1, 175 .default_value = 1,
178 .flags = 0, 176 .flags = 0,
179 .type = V4L2_CTRL_TYPE_BOOLEAN, 177 .type = V4L2_CTRL_TYPE_BOOLEAN,
180 },{ 178 }, {
181 .id = V4L2_CID_AUDIO_BALANCE, 179 .id = V4L2_CID_AUDIO_BALANCE,
182 .name = "Balance", 180 .name = "Balance",
183 .minimum = 0, 181 .minimum = 0,
@@ -191,7 +189,7 @@ static struct v4l2_queryctrl wm8739_qctrl[] = {
191 189
192/* ------------------------------------------------------------------------ */ 190/* ------------------------------------------------------------------------ */
193 191
194static int wm8739_command(struct i2c_client *client, unsigned int cmd, void *arg) 192static int wm8739_command(struct i2c_client *client, unsigned cmd, void *arg)
195{ 193{
196 struct wm8739_state *state = i2c_get_clientdata(client); 194 struct wm8739_state *state = i2c_get_clientdata(client);
197 195
@@ -201,21 +199,26 @@ static int wm8739_command(struct i2c_client *client, unsigned int cmd, void *arg
201 u32 audiofreq = *(u32 *)arg; 199 u32 audiofreq = *(u32 *)arg;
202 200
203 state->clock_freq = audiofreq; 201 state->clock_freq = audiofreq;
204 wm8739_write(client, R9, 0x000); /* de-activate */ 202 /* de-activate */
203 wm8739_write(client, R9, 0x000);
205 switch (audiofreq) { 204 switch (audiofreq) {
206 case 44100: 205 case 44100:
207 wm8739_write(client, R8, 0x020); /* 256fps, fs=44.1k */ 206 /* 256fps, fs=44.1k */
207 wm8739_write(client, R8, 0x020);
208 break; 208 break;
209 case 48000: 209 case 48000:
210 wm8739_write(client, R8, 0x000); /* 256fps, fs=48k */ 210 /* 256fps, fs=48k */
211 wm8739_write(client, R8, 0x000);
211 break; 212 break;
212 case 32000: 213 case 32000:
213 wm8739_write(client, R8, 0x018); /* 256fps, fs=32k */ 214 /* 256fps, fs=32k */
215 wm8739_write(client, R8, 0x018);
214 break; 216 break;
215 default: 217 default:
216 break; 218 break;
217 } 219 }
218 wm8739_write(client, R9, 0x001); /* activate */ 220 /* activate */
221 wm8739_write(client, R9, 0x001);
219 break; 222 break;
220 } 223 }
221 224
@@ -239,7 +242,8 @@ static int wm8739_command(struct i2c_client *client, unsigned int cmd, void *arg
239 } 242 }
240 243
241 case VIDIOC_G_CHIP_IDENT: 244 case VIDIOC_G_CHIP_IDENT:
242 return v4l2_chip_ident_i2c_client(client, arg, V4L2_IDENT_WM8739, 0); 245 return v4l2_chip_ident_i2c_client(client,
246 arg, V4L2_IDENT_WM8739, 0);
243 247
244 case VIDIOC_LOG_STATUS: 248 case VIDIOC_LOG_STATUS:
245 v4l_info(client, "Frequency: %u Hz\n", state->clock_freq); 249 v4l_info(client, "Frequency: %u Hz\n", state->clock_freq);
@@ -268,7 +272,8 @@ static int wm8739_probe(struct i2c_client *client)
268 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 272 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
269 return -EIO; 273 return -EIO;
270 274
271 v4l_info(client, "chip found @ 0x%x (%s)\n", client->addr << 1, client->adapter->name); 275 v4l_info(client, "chip found @ 0x%x (%s)\n",
276 client->addr << 1, client->adapter->name);
272 277
273 state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL); 278 state = kmalloc(sizeof(struct wm8739_state), GFP_KERNEL);
274 if (state == NULL) { 279 if (state == NULL) {
@@ -284,17 +289,23 @@ static int wm8739_probe(struct i2c_client *client)
284 state->clock_freq = 48000; 289 state->clock_freq = 48000;
285 i2c_set_clientdata(client, state); 290 i2c_set_clientdata(client, state);
286 291
287 /* initialize wm8739 */ 292 /* Initialize wm8739 */
288 wm8739_write(client, R15, 0x00); /* reset */ 293
289 wm8739_write(client, R5, 0x000); /* filter setting, high path, offet clear */ 294 /* reset */
290 wm8739_write(client, R6, 0x000); /* ADC, OSC, Power Off mode Disable */ 295 wm8739_write(client, R15, 0x00);
291 wm8739_write(client, R7, 0x049); /* Digital Audio interface format */ 296 /* filter setting, high path, offet clear */
292 /* Enable Master mode */ 297 wm8739_write(client, R5, 0x000);
293 /* 24 bit, MSB first/left justified */ 298 /* ADC, OSC, Power Off mode Disable */
294 wm8739_write(client, R8, 0x000); /* sampling control */ 299 wm8739_write(client, R6, 0x000);
295 /* normal, 256fs, 48KHz sampling rate */ 300 /* Digital Audio interface format:
296 wm8739_write(client, R9, 0x001); /* activate */ 301 Enable Master mode, 24 bit, MSB first/left justified */
297 wm8739_set_audio(client); /* set volume/mute */ 302 wm8739_write(client, R7, 0x049);
303 /* sampling control: normal, 256fs, 48KHz sampling rate */
304 wm8739_write(client, R8, 0x000);
305 /* activate */
306 wm8739_write(client, R9, 0x001);
307 /* set volume/mute */
308 wm8739_set_audio(client);
298 return 0; 309 return 0;
299} 310}
300 311