diff options
-rw-r--r-- | drivers/media/radio/radio-wl1273.c | 360 |
1 files changed, 106 insertions, 254 deletions
diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c index 7ecc8e657663..9e177dccc673 100644 --- a/drivers/media/radio/radio-wl1273.c +++ b/drivers/media/radio/radio-wl1273.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the Texas Instruments WL1273 FM radio. | 2 | * Driver for the Texas Instruments WL1273 FM radio. |
3 | * | 3 | * |
4 | * Copyright (C) 2010 Nokia Corporation | 4 | * Copyright (C) 2011 Nokia Corporation |
5 | * Author: Matti J. Aaltonen <matti.j.aaltonen@nokia.com> | 5 | * Author: Matti J. Aaltonen <matti.j.aaltonen@nokia.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or | 7 | * This program is free software; you can redistribute it and/or |
@@ -104,58 +104,6 @@ static unsigned int rds_buf = 100; | |||
104 | module_param(rds_buf, uint, 0); | 104 | module_param(rds_buf, uint, 0); |
105 | MODULE_PARM_DESC(rds_buf, "Number of RDS buffer entries. Default = 100"); | 105 | MODULE_PARM_DESC(rds_buf, "Number of RDS buffer entries. Default = 100"); |
106 | 106 | ||
107 | static int wl1273_fm_read_reg(struct wl1273_core *core, u8 reg, u16 *value) | ||
108 | { | ||
109 | struct i2c_client *client = core->client; | ||
110 | u8 b[2]; | ||
111 | int r; | ||
112 | |||
113 | r = i2c_smbus_read_i2c_block_data(client, reg, sizeof(b), b); | ||
114 | if (r != 2) { | ||
115 | dev_err(&client->dev, "%s: Read: %d fails.\n", __func__, reg); | ||
116 | return -EREMOTEIO; | ||
117 | } | ||
118 | |||
119 | *value = (u16)b[0] << 8 | b[1]; | ||
120 | |||
121 | return 0; | ||
122 | } | ||
123 | |||
124 | static int wl1273_fm_write_cmd(struct wl1273_core *core, u8 cmd, u16 param) | ||
125 | { | ||
126 | struct i2c_client *client = core->client; | ||
127 | u8 buf[] = { (param >> 8) & 0xff, param & 0xff }; | ||
128 | int r; | ||
129 | |||
130 | r = i2c_smbus_write_i2c_block_data(client, cmd, sizeof(buf), buf); | ||
131 | if (r) { | ||
132 | dev_err(&client->dev, "%s: Cmd: %d fails.\n", __func__, cmd); | ||
133 | return r; | ||
134 | } | ||
135 | |||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | static int wl1273_fm_write_data(struct wl1273_core *core, u8 *data, u16 len) | ||
140 | { | ||
141 | struct i2c_client *client = core->client; | ||
142 | struct i2c_msg msg; | ||
143 | int r; | ||
144 | |||
145 | msg.addr = client->addr; | ||
146 | msg.flags = 0; | ||
147 | msg.buf = data; | ||
148 | msg.len = len; | ||
149 | |||
150 | r = i2c_transfer(client->adapter, &msg, 1); | ||
151 | if (r != 1) { | ||
152 | dev_err(&client->dev, "%s: write error.\n", __func__); | ||
153 | return -EREMOTEIO; | ||
154 | } | ||
155 | |||
156 | return 0; | ||
157 | } | ||
158 | |||
159 | static int wl1273_fm_write_fw(struct wl1273_core *core, | 107 | static int wl1273_fm_write_fw(struct wl1273_core *core, |
160 | __u8 *fw, int len) | 108 | __u8 *fw, int len) |
161 | { | 109 | { |
@@ -188,94 +136,6 @@ static int wl1273_fm_write_fw(struct wl1273_core *core, | |||
188 | return r; | 136 | return r; |
189 | } | 137 | } |
190 | 138 | ||
191 | /** | ||
192 | * wl1273_fm_set_audio() - Set audio mode. | ||
193 | * @core: A pointer to the device struct. | ||
194 | * @new_mode: The new audio mode. | ||
195 | * | ||
196 | * Audio modes are WL1273_AUDIO_DIGITAL and WL1273_AUDIO_ANALOG. | ||
197 | */ | ||
198 | static int wl1273_fm_set_audio(struct wl1273_core *core, unsigned int new_mode) | ||
199 | { | ||
200 | int r = 0; | ||
201 | |||
202 | if (core->mode == WL1273_MODE_OFF || | ||
203 | core->mode == WL1273_MODE_SUSPENDED) | ||
204 | return -EPERM; | ||
205 | |||
206 | if (core->mode == WL1273_MODE_RX && new_mode == WL1273_AUDIO_DIGITAL) { | ||
207 | r = wl1273_fm_write_cmd(core, WL1273_PCM_MODE_SET, | ||
208 | WL1273_PCM_DEF_MODE); | ||
209 | if (r) | ||
210 | goto out; | ||
211 | |||
212 | r = wl1273_fm_write_cmd(core, WL1273_I2S_MODE_CONFIG_SET, | ||
213 | core->i2s_mode); | ||
214 | if (r) | ||
215 | goto out; | ||
216 | |||
217 | r = wl1273_fm_write_cmd(core, WL1273_AUDIO_ENABLE, | ||
218 | WL1273_AUDIO_ENABLE_I2S); | ||
219 | if (r) | ||
220 | goto out; | ||
221 | |||
222 | } else if (core->mode == WL1273_MODE_RX && | ||
223 | new_mode == WL1273_AUDIO_ANALOG) { | ||
224 | r = wl1273_fm_write_cmd(core, WL1273_AUDIO_ENABLE, | ||
225 | WL1273_AUDIO_ENABLE_ANALOG); | ||
226 | if (r) | ||
227 | goto out; | ||
228 | |||
229 | } else if (core->mode == WL1273_MODE_TX && | ||
230 | new_mode == WL1273_AUDIO_DIGITAL) { | ||
231 | r = wl1273_fm_write_cmd(core, WL1273_I2S_MODE_CONFIG_SET, | ||
232 | core->i2s_mode); | ||
233 | if (r) | ||
234 | goto out; | ||
235 | |||
236 | r = wl1273_fm_write_cmd(core, WL1273_AUDIO_IO_SET, | ||
237 | WL1273_AUDIO_IO_SET_I2S); | ||
238 | if (r) | ||
239 | goto out; | ||
240 | |||
241 | } else if (core->mode == WL1273_MODE_TX && | ||
242 | new_mode == WL1273_AUDIO_ANALOG) { | ||
243 | r = wl1273_fm_write_cmd(core, WL1273_AUDIO_IO_SET, | ||
244 | WL1273_AUDIO_IO_SET_ANALOG); | ||
245 | if (r) | ||
246 | goto out; | ||
247 | } | ||
248 | |||
249 | core->audio_mode = new_mode; | ||
250 | out: | ||
251 | return r; | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * wl1273_fm_set_volume() - Set volume. | ||
256 | * @core: A pointer to the device struct. | ||
257 | * @volume: The new volume value. | ||
258 | */ | ||
259 | static int wl1273_fm_set_volume(struct wl1273_core *core, unsigned int volume) | ||
260 | { | ||
261 | u16 val; | ||
262 | int r; | ||
263 | |||
264 | if (volume > WL1273_MAX_VOLUME) | ||
265 | return -EINVAL; | ||
266 | |||
267 | if (core->volume == volume) | ||
268 | return 0; | ||
269 | |||
270 | val = volume; | ||
271 | r = wl1273_fm_read_reg(core, WL1273_VOLUME_SET, &val); | ||
272 | if (r) | ||
273 | return r; | ||
274 | |||
275 | core->volume = volume; | ||
276 | return 0; | ||
277 | } | ||
278 | |||
279 | #define WL1273_FIFO_HAS_DATA(status) (1 << 5 & status) | 139 | #define WL1273_FIFO_HAS_DATA(status) (1 << 5 & status) |
280 | #define WL1273_RDS_CORRECTABLE_ERROR (1 << 3) | 140 | #define WL1273_RDS_CORRECTABLE_ERROR (1 << 3) |
281 | #define WL1273_RDS_UNCORRECTABLE_ERROR (1 << 4) | 141 | #define WL1273_RDS_UNCORRECTABLE_ERROR (1 << 4) |
@@ -306,7 +166,7 @@ static int wl1273_fm_rds(struct wl1273_device *radio) | |||
306 | if (core->mode != WL1273_MODE_RX) | 166 | if (core->mode != WL1273_MODE_RX) |
307 | return 0; | 167 | return 0; |
308 | 168 | ||
309 | r = wl1273_fm_read_reg(core, WL1273_RDS_SYNC_GET, &val); | 169 | r = core->read(core, WL1273_RDS_SYNC_GET, &val); |
310 | if (r) | 170 | if (r) |
311 | return r; | 171 | return r; |
312 | 172 | ||
@@ -374,7 +234,7 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id) | |||
374 | u16 flags; | 234 | u16 flags; |
375 | int r; | 235 | int r; |
376 | 236 | ||
377 | r = wl1273_fm_read_reg(core, WL1273_FLAG_GET, &flags); | 237 | r = core->read(core, WL1273_FLAG_GET, &flags); |
378 | if (r) | 238 | if (r) |
379 | goto out; | 239 | goto out; |
380 | 240 | ||
@@ -398,7 +258,7 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id) | |||
398 | if (flags & WL1273_LEV_EVENT) { | 258 | if (flags & WL1273_LEV_EVENT) { |
399 | u16 level; | 259 | u16 level; |
400 | 260 | ||
401 | r = wl1273_fm_read_reg(core, WL1273_RSSI_LVL_GET, &level); | 261 | r = core->read(core, WL1273_RSSI_LVL_GET, &level); |
402 | if (r) | 262 | if (r) |
403 | goto out; | 263 | goto out; |
404 | 264 | ||
@@ -439,8 +299,8 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id) | |||
439 | dev_dbg(radio->dev, "IRQ: FR:\n"); | 299 | dev_dbg(radio->dev, "IRQ: FR:\n"); |
440 | 300 | ||
441 | if (core->mode == WL1273_MODE_RX) { | 301 | if (core->mode == WL1273_MODE_RX) { |
442 | r = wl1273_fm_write_cmd(core, WL1273_TUNER_MODE_SET, | 302 | r = core->write(core, WL1273_TUNER_MODE_SET, |
443 | TUNER_MODE_STOP_SEARCH); | 303 | TUNER_MODE_STOP_SEARCH); |
444 | if (r) { | 304 | if (r) { |
445 | dev_err(radio->dev, | 305 | dev_err(radio->dev, |
446 | "%s: TUNER_MODE_SET fails: %d\n", | 306 | "%s: TUNER_MODE_SET fails: %d\n", |
@@ -448,7 +308,7 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id) | |||
448 | goto out; | 308 | goto out; |
449 | } | 309 | } |
450 | 310 | ||
451 | r = wl1273_fm_read_reg(core, WL1273_FREQ_SET, &freq); | 311 | r = core->read(core, WL1273_FREQ_SET, &freq); |
452 | if (r) | 312 | if (r) |
453 | goto out; | 313 | goto out; |
454 | 314 | ||
@@ -467,7 +327,7 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id) | |||
467 | dev_dbg(radio->dev, "%dkHz\n", radio->rx_frequency); | 327 | dev_dbg(radio->dev, "%dkHz\n", radio->rx_frequency); |
468 | 328 | ||
469 | } else { | 329 | } else { |
470 | r = wl1273_fm_read_reg(core, WL1273_CHANL_SET, &freq); | 330 | r = core->read(core, WL1273_CHANL_SET, &freq); |
471 | if (r) | 331 | if (r) |
472 | goto out; | 332 | goto out; |
473 | 333 | ||
@@ -477,8 +337,7 @@ static irqreturn_t wl1273_fm_irq_thread_handler(int irq, void *dev_id) | |||
477 | } | 337 | } |
478 | 338 | ||
479 | out: | 339 | out: |
480 | wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, | 340 | core->write(core, WL1273_INT_MASK_SET, radio->irq_flags); |
481 | radio->irq_flags); | ||
482 | complete(&radio->busy); | 341 | complete(&radio->busy); |
483 | 342 | ||
484 | return IRQ_HANDLED; | 343 | return IRQ_HANDLED; |
@@ -512,7 +371,7 @@ static int wl1273_fm_set_tx_freq(struct wl1273_device *radio, unsigned int freq) | |||
512 | dev_dbg(radio->dev, "%s: freq: %d kHz\n", __func__, freq); | 371 | dev_dbg(radio->dev, "%s: freq: %d kHz\n", __func__, freq); |
513 | 372 | ||
514 | /* Set the current tx channel */ | 373 | /* Set the current tx channel */ |
515 | r = wl1273_fm_write_cmd(core, WL1273_CHANL_SET, freq / 10); | 374 | r = core->write(core, WL1273_CHANL_SET, freq / 10); |
516 | if (r) | 375 | if (r) |
517 | return r; | 376 | return r; |
518 | 377 | ||
@@ -526,7 +385,7 @@ static int wl1273_fm_set_tx_freq(struct wl1273_device *radio, unsigned int freq) | |||
526 | dev_dbg(radio->dev, "WL1273_CHANL_SET: %d\n", r); | 385 | dev_dbg(radio->dev, "WL1273_CHANL_SET: %d\n", r); |
527 | 386 | ||
528 | /* Enable the output power */ | 387 | /* Enable the output power */ |
529 | r = wl1273_fm_write_cmd(core, WL1273_POWER_ENB_SET, 1); | 388 | r = core->write(core, WL1273_POWER_ENB_SET, 1); |
530 | if (r) | 389 | if (r) |
531 | return r; | 390 | return r; |
532 | 391 | ||
@@ -566,20 +425,20 @@ static int wl1273_fm_set_rx_freq(struct wl1273_device *radio, unsigned int freq) | |||
566 | 425 | ||
567 | dev_dbg(radio->dev, "%s: %dkHz\n", __func__, freq); | 426 | dev_dbg(radio->dev, "%s: %dkHz\n", __func__, freq); |
568 | 427 | ||
569 | wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, radio->irq_flags); | 428 | core->write(core, WL1273_INT_MASK_SET, radio->irq_flags); |
570 | 429 | ||
571 | if (radio->band == WL1273_BAND_JAPAN) | 430 | if (radio->band == WL1273_BAND_JAPAN) |
572 | f = (freq - WL1273_BAND_JAPAN_LOW) / 50; | 431 | f = (freq - WL1273_BAND_JAPAN_LOW) / 50; |
573 | else | 432 | else |
574 | f = (freq - WL1273_BAND_OTHER_LOW) / 50; | 433 | f = (freq - WL1273_BAND_OTHER_LOW) / 50; |
575 | 434 | ||
576 | r = wl1273_fm_write_cmd(core, WL1273_FREQ_SET, f); | 435 | r = core->write(core, WL1273_FREQ_SET, f); |
577 | if (r) { | 436 | if (r) { |
578 | dev_err(radio->dev, "FREQ_SET fails\n"); | 437 | dev_err(radio->dev, "FREQ_SET fails\n"); |
579 | goto err; | 438 | goto err; |
580 | } | 439 | } |
581 | 440 | ||
582 | r = wl1273_fm_write_cmd(core, WL1273_TUNER_MODE_SET, TUNER_MODE_PRESET); | 441 | r = core->write(core, WL1273_TUNER_MODE_SET, TUNER_MODE_PRESET); |
583 | if (r) { | 442 | if (r) { |
584 | dev_err(radio->dev, "TUNER_MODE_SET fails\n"); | 443 | dev_err(radio->dev, "TUNER_MODE_SET fails\n"); |
585 | goto err; | 444 | goto err; |
@@ -609,7 +468,7 @@ static int wl1273_fm_get_freq(struct wl1273_device *radio) | |||
609 | int r; | 468 | int r; |
610 | 469 | ||
611 | if (core->mode == WL1273_MODE_RX) { | 470 | if (core->mode == WL1273_MODE_RX) { |
612 | r = wl1273_fm_read_reg(core, WL1273_FREQ_SET, &f); | 471 | r = core->read(core, WL1273_FREQ_SET, &f); |
613 | if (r) | 472 | if (r) |
614 | return r; | 473 | return r; |
615 | 474 | ||
@@ -619,7 +478,7 @@ static int wl1273_fm_get_freq(struct wl1273_device *radio) | |||
619 | else | 478 | else |
620 | freq = WL1273_BAND_OTHER_LOW + 50 * f; | 479 | freq = WL1273_BAND_OTHER_LOW + 50 * f; |
621 | } else { | 480 | } else { |
622 | r = wl1273_fm_read_reg(core, WL1273_CHANL_SET, &f); | 481 | r = core->read(core, WL1273_CHANL_SET, &f); |
623 | if (r) | 482 | if (r) |
624 | return r; | 483 | return r; |
625 | 484 | ||
@@ -670,7 +529,7 @@ static int wl1273_fm_upload_firmware_patch(struct wl1273_device *radio) | |||
670 | } | 529 | } |
671 | 530 | ||
672 | /* ignore possible error here */ | 531 | /* ignore possible error here */ |
673 | wl1273_fm_write_cmd(core, WL1273_RESET, 0); | 532 | core->write(core, WL1273_RESET, 0); |
674 | 533 | ||
675 | dev_dbg(dev, "%s - download OK, r: %d\n", __func__, r); | 534 | dev_dbg(dev, "%s - download OK, r: %d\n", __func__, r); |
676 | out: | 535 | out: |
@@ -683,14 +542,14 @@ static int wl1273_fm_stop(struct wl1273_device *radio) | |||
683 | struct wl1273_core *core = radio->core; | 542 | struct wl1273_core *core = radio->core; |
684 | 543 | ||
685 | if (core->mode == WL1273_MODE_RX) { | 544 | if (core->mode == WL1273_MODE_RX) { |
686 | int r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, | 545 | int r = core->write(core, WL1273_POWER_SET, |
687 | WL1273_POWER_SET_OFF); | 546 | WL1273_POWER_SET_OFF); |
688 | if (r) | 547 | if (r) |
689 | dev_err(radio->dev, "%s: POWER_SET fails: %d\n", | 548 | dev_err(radio->dev, "%s: POWER_SET fails: %d\n", |
690 | __func__, r); | 549 | __func__, r); |
691 | } else if (core->mode == WL1273_MODE_TX) { | 550 | } else if (core->mode == WL1273_MODE_TX) { |
692 | int r = wl1273_fm_write_cmd(core, WL1273_PUPD_SET, | 551 | int r = core->write(core, WL1273_PUPD_SET, |
693 | WL1273_PUPD_SET_OFF); | 552 | WL1273_PUPD_SET_OFF); |
694 | if (r) | 553 | if (r) |
695 | dev_err(radio->dev, | 554 | dev_err(radio->dev, |
696 | "%s: PUPD_SET fails: %d\n", __func__, r); | 555 | "%s: PUPD_SET fails: %d\n", __func__, r); |
@@ -725,11 +584,11 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode) | |||
725 | val |= WL1273_POWER_SET_RDS; | 584 | val |= WL1273_POWER_SET_RDS; |
726 | 585 | ||
727 | /* If this fails try again */ | 586 | /* If this fails try again */ |
728 | r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, val); | 587 | r = core->write(core, WL1273_POWER_SET, val); |
729 | if (r) { | 588 | if (r) { |
730 | msleep(100); | 589 | msleep(100); |
731 | 590 | ||
732 | r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, val); | 591 | r = core->write(core, WL1273_POWER_SET, val); |
733 | if (r) { | 592 | if (r) { |
734 | dev_err(dev, "%s: POWER_SET fails\n", __func__); | 593 | dev_err(dev, "%s: POWER_SET fails\n", __func__); |
735 | goto fail; | 594 | goto fail; |
@@ -742,11 +601,10 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode) | |||
742 | 601 | ||
743 | } else if (new_mode == WL1273_MODE_TX) { | 602 | } else if (new_mode == WL1273_MODE_TX) { |
744 | /* If this fails try again once */ | 603 | /* If this fails try again once */ |
745 | r = wl1273_fm_write_cmd(core, WL1273_PUPD_SET, | 604 | r = core->write(core, WL1273_PUPD_SET, WL1273_PUPD_SET_ON); |
746 | WL1273_PUPD_SET_ON); | ||
747 | if (r) { | 605 | if (r) { |
748 | msleep(100); | 606 | msleep(100); |
749 | r = wl1273_fm_write_cmd(core, WL1273_PUPD_SET, | 607 | r = core->write(core, WL1273_PUPD_SET, |
750 | WL1273_PUPD_SET_ON); | 608 | WL1273_PUPD_SET_ON); |
751 | if (r) { | 609 | if (r) { |
752 | dev_err(dev, "%s: PUPD_SET fails\n", __func__); | 610 | dev_err(dev, "%s: PUPD_SET fails\n", __func__); |
@@ -755,9 +613,9 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode) | |||
755 | } | 613 | } |
756 | 614 | ||
757 | if (radio->rds_on) | 615 | if (radio->rds_on) |
758 | r = wl1273_fm_write_cmd(core, WL1273_RDS_DATA_ENB, 1); | 616 | r = core->write(core, WL1273_RDS_DATA_ENB, 1); |
759 | else | 617 | else |
760 | r = wl1273_fm_write_cmd(core, WL1273_RDS_DATA_ENB, 0); | 618 | r = core->write(core, WL1273_RDS_DATA_ENB, 0); |
761 | } else { | 619 | } else { |
762 | dev_warn(dev, "%s: Illegal mode.\n", __func__); | 620 | dev_warn(dev, "%s: Illegal mode.\n", __func__); |
763 | } | 621 | } |
@@ -777,14 +635,14 @@ static int wl1273_fm_start(struct wl1273_device *radio, int new_mode) | |||
777 | if (radio->rds_on) | 635 | if (radio->rds_on) |
778 | val |= WL1273_POWER_SET_RDS; | 636 | val |= WL1273_POWER_SET_RDS; |
779 | 637 | ||
780 | r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, val); | 638 | r = core->write(core, WL1273_POWER_SET, val); |
781 | if (r) { | 639 | if (r) { |
782 | dev_err(dev, "%s: POWER_SET fails\n", __func__); | 640 | dev_err(dev, "%s: POWER_SET fails\n", __func__); |
783 | goto fail; | 641 | goto fail; |
784 | } | 642 | } |
785 | } else if (new_mode == WL1273_MODE_TX) { | 643 | } else if (new_mode == WL1273_MODE_TX) { |
786 | r = wl1273_fm_write_cmd(core, WL1273_PUPD_SET, | 644 | r = core->write(core, WL1273_PUPD_SET, |
787 | WL1273_PUPD_SET_ON); | 645 | WL1273_PUPD_SET_ON); |
788 | if (r) { | 646 | if (r) { |
789 | dev_err(dev, "%s: PUPD_SET fails\n", __func__); | 647 | dev_err(dev, "%s: PUPD_SET fails\n", __func__); |
790 | goto fail; | 648 | goto fail; |
@@ -808,10 +666,10 @@ static int wl1273_fm_suspend(struct wl1273_device *radio) | |||
808 | 666 | ||
809 | /* Cannot go from OFF to SUSPENDED */ | 667 | /* Cannot go from OFF to SUSPENDED */ |
810 | if (core->mode == WL1273_MODE_RX) | 668 | if (core->mode == WL1273_MODE_RX) |
811 | r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, | 669 | r = core->write(core, WL1273_POWER_SET, |
812 | WL1273_POWER_SET_RETENTION); | 670 | WL1273_POWER_SET_RETENTION); |
813 | else if (core->mode == WL1273_MODE_TX) | 671 | else if (core->mode == WL1273_MODE_TX) |
814 | r = wl1273_fm_write_cmd(core, WL1273_PUPD_SET, | 672 | r = core->write(core, WL1273_PUPD_SET, |
815 | WL1273_PUPD_SET_RETENTION); | 673 | WL1273_PUPD_SET_RETENTION); |
816 | else | 674 | else |
817 | r = -EINVAL; | 675 | r = -EINVAL; |
@@ -852,8 +710,7 @@ static int wl1273_fm_set_mode(struct wl1273_device *radio, int mode) | |||
852 | } | 710 | } |
853 | 711 | ||
854 | core->mode = mode; | 712 | core->mode = mode; |
855 | r = wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, | 713 | r = core->write(core, WL1273_INT_MASK_SET, radio->irq_flags); |
856 | radio->irq_flags); | ||
857 | if (r) { | 714 | if (r) { |
858 | dev_err(dev, "INT_MASK_SET fails.\n"); | 715 | dev_err(dev, "INT_MASK_SET fails.\n"); |
859 | goto out; | 716 | goto out; |
@@ -951,22 +808,21 @@ static int wl1273_fm_set_seek(struct wl1273_device *radio, | |||
951 | INIT_COMPLETION(radio->busy); | 808 | INIT_COMPLETION(radio->busy); |
952 | dev_dbg(radio->dev, "%s: BUSY\n", __func__); | 809 | dev_dbg(radio->dev, "%s: BUSY\n", __func__); |
953 | 810 | ||
954 | r = wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, radio->irq_flags); | 811 | r = core->write(core, WL1273_INT_MASK_SET, radio->irq_flags); |
955 | if (r) | 812 | if (r) |
956 | goto out; | 813 | goto out; |
957 | 814 | ||
958 | dev_dbg(radio->dev, "%s\n", __func__); | 815 | dev_dbg(radio->dev, "%s\n", __func__); |
959 | 816 | ||
960 | r = wl1273_fm_write_cmd(core, WL1273_SEARCH_LVL_SET, level); | 817 | r = core->write(core, WL1273_SEARCH_LVL_SET, level); |
961 | if (r) | 818 | if (r) |
962 | goto out; | 819 | goto out; |
963 | 820 | ||
964 | r = wl1273_fm_write_cmd(core, WL1273_SEARCH_DIR_SET, dir); | 821 | r = core->write(core, WL1273_SEARCH_DIR_SET, dir); |
965 | if (r) | 822 | if (r) |
966 | goto out; | 823 | goto out; |
967 | 824 | ||
968 | r = wl1273_fm_write_cmd(core, WL1273_TUNER_MODE_SET, | 825 | r = core->write(core, WL1273_TUNER_MODE_SET, TUNER_MODE_AUTO_SEEK); |
969 | TUNER_MODE_AUTO_SEEK); | ||
970 | if (r) | 826 | if (r) |
971 | goto out; | 827 | goto out; |
972 | 828 | ||
@@ -994,8 +850,7 @@ static int wl1273_fm_set_seek(struct wl1273_device *radio, | |||
994 | INIT_COMPLETION(radio->busy); | 850 | INIT_COMPLETION(radio->busy); |
995 | dev_dbg(radio->dev, "%s: BUSY\n", __func__); | 851 | dev_dbg(radio->dev, "%s: BUSY\n", __func__); |
996 | 852 | ||
997 | r = wl1273_fm_write_cmd(core, WL1273_TUNER_MODE_SET, | 853 | r = core->write(core, WL1273_TUNER_MODE_SET, TUNER_MODE_AUTO_SEEK); |
998 | TUNER_MODE_AUTO_SEEK); | ||
999 | if (r) | 854 | if (r) |
1000 | goto out; | 855 | goto out; |
1001 | 856 | ||
@@ -1020,7 +875,7 @@ static unsigned int wl1273_fm_get_tx_ctune(struct wl1273_device *radio) | |||
1020 | core->mode == WL1273_MODE_SUSPENDED) | 875 | core->mode == WL1273_MODE_SUSPENDED) |
1021 | return -EPERM; | 876 | return -EPERM; |
1022 | 877 | ||
1023 | r = wl1273_fm_read_reg(core, WL1273_READ_FMANT_TUNE_VALUE, &val); | 878 | r = core->read(core, WL1273_READ_FMANT_TUNE_VALUE, &val); |
1024 | if (r) { | 879 | if (r) { |
1025 | dev_err(dev, "%s: read error: %d\n", __func__, r); | 880 | dev_err(dev, "%s: read error: %d\n", __func__, r); |
1026 | goto out; | 881 | goto out; |
@@ -1066,7 +921,7 @@ static int wl1273_fm_set_preemphasis(struct wl1273_device *radio, | |||
1066 | goto out; | 921 | goto out; |
1067 | } | 922 | } |
1068 | 923 | ||
1069 | r = wl1273_fm_write_cmd(core, WL1273_PREMPH_SET, em); | 924 | r = core->write(core, WL1273_PREMPH_SET, em); |
1070 | if (r) | 925 | if (r) |
1071 | goto out; | 926 | goto out; |
1072 | 927 | ||
@@ -1086,7 +941,7 @@ static int wl1273_fm_rds_on(struct wl1273_device *radio) | |||
1086 | if (radio->rds_on) | 941 | if (radio->rds_on) |
1087 | return 0; | 942 | return 0; |
1088 | 943 | ||
1089 | r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, | 944 | r = core->write(core, WL1273_POWER_SET, |
1090 | WL1273_POWER_SET_FM | WL1273_POWER_SET_RDS); | 945 | WL1273_POWER_SET_FM | WL1273_POWER_SET_RDS); |
1091 | if (r) | 946 | if (r) |
1092 | goto out; | 947 | goto out; |
@@ -1108,7 +963,7 @@ static int wl1273_fm_rds_off(struct wl1273_device *radio) | |||
1108 | 963 | ||
1109 | radio->irq_flags &= ~WL1273_RDS_EVENT; | 964 | radio->irq_flags &= ~WL1273_RDS_EVENT; |
1110 | 965 | ||
1111 | r = wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, radio->irq_flags); | 966 | r = core->write(core, WL1273_INT_MASK_SET, radio->irq_flags); |
1112 | if (r) | 967 | if (r) |
1113 | goto out; | 968 | goto out; |
1114 | 969 | ||
@@ -1120,7 +975,7 @@ static int wl1273_fm_rds_off(struct wl1273_device *radio) | |||
1120 | 975 | ||
1121 | dev_dbg(radio->dev, "%s\n", __func__); | 976 | dev_dbg(radio->dev, "%s\n", __func__); |
1122 | 977 | ||
1123 | r = wl1273_fm_write_cmd(core, WL1273_POWER_SET, WL1273_POWER_SET_FM); | 978 | r = core->write(core, WL1273_POWER_SET, WL1273_POWER_SET_FM); |
1124 | if (r) | 979 | if (r) |
1125 | goto out; | 980 | goto out; |
1126 | 981 | ||
@@ -1143,14 +998,14 @@ static int wl1273_fm_set_rds(struct wl1273_device *radio, unsigned int new_mode) | |||
1143 | return -EPERM; | 998 | return -EPERM; |
1144 | 999 | ||
1145 | if (new_mode == WL1273_RDS_RESET) { | 1000 | if (new_mode == WL1273_RDS_RESET) { |
1146 | r = wl1273_fm_write_cmd(core, WL1273_RDS_CNTRL_SET, 1); | 1001 | r = core->write(core, WL1273_RDS_CNTRL_SET, 1); |
1147 | return r; | 1002 | return r; |
1148 | } | 1003 | } |
1149 | 1004 | ||
1150 | if (core->mode == WL1273_MODE_TX && new_mode == WL1273_RDS_OFF) { | 1005 | if (core->mode == WL1273_MODE_TX && new_mode == WL1273_RDS_OFF) { |
1151 | r = wl1273_fm_write_cmd(core, WL1273_RDS_DATA_ENB, 0); | 1006 | r = core->write(core, WL1273_RDS_DATA_ENB, 0); |
1152 | } else if (core->mode == WL1273_MODE_TX && new_mode == WL1273_RDS_ON) { | 1007 | } else if (core->mode == WL1273_MODE_TX && new_mode == WL1273_RDS_ON) { |
1153 | r = wl1273_fm_write_cmd(core, WL1273_RDS_DATA_ENB, 1); | 1008 | r = core->write(core, WL1273_RDS_DATA_ENB, 1); |
1154 | } else if (core->mode == WL1273_MODE_RX && new_mode == WL1273_RDS_OFF) { | 1009 | } else if (core->mode == WL1273_MODE_RX && new_mode == WL1273_RDS_OFF) { |
1155 | r = wl1273_fm_rds_off(radio); | 1010 | r = wl1273_fm_rds_off(radio); |
1156 | } else if (core->mode == WL1273_MODE_RX && new_mode == WL1273_RDS_ON) { | 1011 | } else if (core->mode == WL1273_MODE_RX && new_mode == WL1273_RDS_ON) { |
@@ -1171,12 +1026,13 @@ static ssize_t wl1273_fm_fops_write(struct file *file, const char __user *buf, | |||
1171 | size_t count, loff_t *ppos) | 1026 | size_t count, loff_t *ppos) |
1172 | { | 1027 | { |
1173 | struct wl1273_device *radio = video_get_drvdata(video_devdata(file)); | 1028 | struct wl1273_device *radio = video_get_drvdata(video_devdata(file)); |
1029 | struct wl1273_core *core = radio->core; | ||
1174 | u16 val; | 1030 | u16 val; |
1175 | int r; | 1031 | int r; |
1176 | 1032 | ||
1177 | dev_dbg(radio->dev, "%s\n", __func__); | 1033 | dev_dbg(radio->dev, "%s\n", __func__); |
1178 | 1034 | ||
1179 | if (radio->core->mode != WL1273_MODE_TX) | 1035 | if (core->mode != WL1273_MODE_TX) |
1180 | return count; | 1036 | return count; |
1181 | 1037 | ||
1182 | if (radio->rds_users == 0) { | 1038 | if (radio->rds_users == 0) { |
@@ -1184,7 +1040,7 @@ static ssize_t wl1273_fm_fops_write(struct file *file, const char __user *buf, | |||
1184 | return 0; | 1040 | return 0; |
1185 | } | 1041 | } |
1186 | 1042 | ||
1187 | if (mutex_lock_interruptible(&radio->core->lock)) | 1043 | if (mutex_lock_interruptible(&core->lock)) |
1188 | return -EINTR; | 1044 | return -EINTR; |
1189 | /* | 1045 | /* |
1190 | * Multiple processes can open the device, but only | 1046 | * Multiple processes can open the device, but only |
@@ -1202,7 +1058,7 @@ static ssize_t wl1273_fm_fops_write(struct file *file, const char __user *buf, | |||
1202 | else | 1058 | else |
1203 | val = count; | 1059 | val = count; |
1204 | 1060 | ||
1205 | wl1273_fm_write_cmd(radio->core, WL1273_RDS_CONFIG_DATA_SET, val); | 1061 | core->write(core, WL1273_RDS_CONFIG_DATA_SET, val); |
1206 | 1062 | ||
1207 | if (copy_from_user(radio->write_buf + 1, buf, val)) { | 1063 | if (copy_from_user(radio->write_buf + 1, buf, val)) { |
1208 | r = -EFAULT; | 1064 | r = -EFAULT; |
@@ -1213,11 +1069,11 @@ static ssize_t wl1273_fm_fops_write(struct file *file, const char __user *buf, | |||
1213 | dev_dbg(radio->dev, "From user: \"%s\"\n", radio->write_buf); | 1069 | dev_dbg(radio->dev, "From user: \"%s\"\n", radio->write_buf); |
1214 | 1070 | ||
1215 | radio->write_buf[0] = WL1273_RDS_DATA_SET; | 1071 | radio->write_buf[0] = WL1273_RDS_DATA_SET; |
1216 | wl1273_fm_write_data(radio->core, radio->write_buf, val + 1); | 1072 | core->write_data(core, radio->write_buf, val + 1); |
1217 | 1073 | ||
1218 | r = val; | 1074 | r = val; |
1219 | out: | 1075 | out: |
1220 | mutex_unlock(&radio->core->lock); | 1076 | mutex_unlock(&core->lock); |
1221 | 1077 | ||
1222 | return r; | 1078 | return r; |
1223 | } | 1079 | } |
@@ -1263,8 +1119,8 @@ static int wl1273_fm_fops_open(struct file *file) | |||
1263 | 1119 | ||
1264 | radio->irq_flags |= WL1273_RDS_EVENT; | 1120 | radio->irq_flags |= WL1273_RDS_EVENT; |
1265 | 1121 | ||
1266 | r = wl1273_fm_write_cmd(core, WL1273_INT_MASK_SET, | 1122 | r = core->write(core, WL1273_INT_MASK_SET, |
1267 | radio->irq_flags); | 1123 | radio->irq_flags); |
1268 | if (r) { | 1124 | if (r) { |
1269 | mutex_unlock(&core->lock); | 1125 | mutex_unlock(&core->lock); |
1270 | goto out; | 1126 | goto out; |
@@ -1295,9 +1151,9 @@ static int wl1273_fm_fops_release(struct file *file) | |||
1295 | radio->irq_flags &= ~WL1273_RDS_EVENT; | 1151 | radio->irq_flags &= ~WL1273_RDS_EVENT; |
1296 | 1152 | ||
1297 | if (core->mode == WL1273_MODE_RX) { | 1153 | if (core->mode == WL1273_MODE_RX) { |
1298 | r = wl1273_fm_write_cmd(core, | 1154 | r = core->write(core, |
1299 | WL1273_INT_MASK_SET, | 1155 | WL1273_INT_MASK_SET, |
1300 | radio->irq_flags); | 1156 | radio->irq_flags); |
1301 | if (r) { | 1157 | if (r) { |
1302 | mutex_unlock(&core->lock); | 1158 | mutex_unlock(&core->lock); |
1303 | goto out; | 1159 | goto out; |
@@ -1324,7 +1180,7 @@ static ssize_t wl1273_fm_fops_read(struct file *file, char __user *buf, | |||
1324 | 1180 | ||
1325 | dev_dbg(radio->dev, "%s\n", __func__); | 1181 | dev_dbg(radio->dev, "%s\n", __func__); |
1326 | 1182 | ||
1327 | if (radio->core->mode != WL1273_MODE_RX) | 1183 | if (core->mode != WL1273_MODE_RX) |
1328 | return 0; | 1184 | return 0; |
1329 | 1185 | ||
1330 | if (radio->rds_users == 0) { | 1186 | if (radio->rds_users == 0) { |
@@ -1345,7 +1201,7 @@ static ssize_t wl1273_fm_fops_read(struct file *file, char __user *buf, | |||
1345 | } | 1201 | } |
1346 | radio->owner = file; | 1202 | radio->owner = file; |
1347 | 1203 | ||
1348 | r = wl1273_fm_read_reg(core, WL1273_RDS_SYNC_GET, &val); | 1204 | r = core->read(core, WL1273_RDS_SYNC_GET, &val); |
1349 | if (r) { | 1205 | if (r) { |
1350 | dev_err(radio->dev, "%s: Get RDS_SYNC fails.\n", __func__); | 1206 | dev_err(radio->dev, "%s: Get RDS_SYNC fails.\n", __func__); |
1351 | goto out; | 1207 | goto out; |
@@ -1466,23 +1322,24 @@ static int wl1273_fm_vidioc_s_input(struct file *file, void *priv, | |||
1466 | */ | 1322 | */ |
1467 | static int wl1273_fm_set_tx_power(struct wl1273_device *radio, u16 power) | 1323 | static int wl1273_fm_set_tx_power(struct wl1273_device *radio, u16 power) |
1468 | { | 1324 | { |
1325 | struct wl1273_core *core = radio->core; | ||
1469 | int r; | 1326 | int r; |
1470 | 1327 | ||
1471 | if (radio->core->mode == WL1273_MODE_OFF || | 1328 | if (core->mode == WL1273_MODE_OFF || |
1472 | radio->core->mode == WL1273_MODE_SUSPENDED) | 1329 | core->mode == WL1273_MODE_SUSPENDED) |
1473 | return -EPERM; | 1330 | return -EPERM; |
1474 | 1331 | ||
1475 | mutex_lock(&radio->core->lock); | 1332 | mutex_lock(&core->lock); |
1476 | 1333 | ||
1477 | /* Convert the dBuV value to chip presentation */ | 1334 | /* Convert the dBuV value to chip presentation */ |
1478 | r = wl1273_fm_write_cmd(radio->core, WL1273_POWER_LEV_SET, 122 - power); | 1335 | r = core->write(core, WL1273_POWER_LEV_SET, 122 - power); |
1479 | if (r) | 1336 | if (r) |
1480 | goto out; | 1337 | goto out; |
1481 | 1338 | ||
1482 | radio->tx_power = power; | 1339 | radio->tx_power = power; |
1483 | 1340 | ||
1484 | out: | 1341 | out: |
1485 | mutex_unlock(&radio->core->lock); | 1342 | mutex_unlock(&core->lock); |
1486 | return r; | 1343 | return r; |
1487 | } | 1344 | } |
1488 | 1345 | ||
@@ -1493,23 +1350,24 @@ out: | |||
1493 | static int wl1273_fm_tx_set_spacing(struct wl1273_device *radio, | 1350 | static int wl1273_fm_tx_set_spacing(struct wl1273_device *radio, |
1494 | unsigned int spacing) | 1351 | unsigned int spacing) |
1495 | { | 1352 | { |
1353 | struct wl1273_core *core = radio->core; | ||
1496 | int r; | 1354 | int r; |
1497 | 1355 | ||
1498 | if (spacing == 0) { | 1356 | if (spacing == 0) { |
1499 | r = wl1273_fm_write_cmd(radio->core, WL1273_SCAN_SPACING_SET, | 1357 | r = core->write(core, WL1273_SCAN_SPACING_SET, |
1500 | WL1273_SPACING_100kHz); | 1358 | WL1273_SPACING_100kHz); |
1501 | radio->spacing = 100; | 1359 | radio->spacing = 100; |
1502 | } else if (spacing - 50000 < 25000) { | 1360 | } else if (spacing - 50000 < 25000) { |
1503 | r = wl1273_fm_write_cmd(radio->core, WL1273_SCAN_SPACING_SET, | 1361 | r = core->write(core, WL1273_SCAN_SPACING_SET, |
1504 | WL1273_SPACING_50kHz); | 1362 | WL1273_SPACING_50kHz); |
1505 | radio->spacing = 50; | 1363 | radio->spacing = 50; |
1506 | } else if (spacing - 100000 < 50000) { | 1364 | } else if (spacing - 100000 < 50000) { |
1507 | r = wl1273_fm_write_cmd(radio->core, WL1273_SCAN_SPACING_SET, | 1365 | r = core->write(core, WL1273_SCAN_SPACING_SET, |
1508 | WL1273_SPACING_100kHz); | 1366 | WL1273_SPACING_100kHz); |
1509 | radio->spacing = 100; | 1367 | radio->spacing = 100; |
1510 | } else { | 1368 | } else { |
1511 | r = wl1273_fm_write_cmd(radio->core, WL1273_SCAN_SPACING_SET, | 1369 | r = core->write(core, WL1273_SCAN_SPACING_SET, |
1512 | WL1273_SPACING_200kHz); | 1370 | WL1273_SPACING_200kHz); |
1513 | radio->spacing = 200; | 1371 | radio->spacing = 200; |
1514 | } | 1372 | } |
1515 | 1373 | ||
@@ -1567,17 +1425,17 @@ static int wl1273_fm_vidioc_s_ctrl(struct v4l2_ctrl *ctrl) | |||
1567 | return -EINTR; | 1425 | return -EINTR; |
1568 | 1426 | ||
1569 | if (core->mode == WL1273_MODE_RX && ctrl->val) | 1427 | if (core->mode == WL1273_MODE_RX && ctrl->val) |
1570 | r = wl1273_fm_write_cmd(core, | 1428 | r = core->write(core, |
1571 | WL1273_MUTE_STATUS_SET, | 1429 | WL1273_MUTE_STATUS_SET, |
1572 | WL1273_MUTE_HARD_LEFT | | 1430 | WL1273_MUTE_HARD_LEFT | |
1573 | WL1273_MUTE_HARD_RIGHT); | 1431 | WL1273_MUTE_HARD_RIGHT); |
1574 | else if (core->mode == WL1273_MODE_RX) | 1432 | else if (core->mode == WL1273_MODE_RX) |
1575 | r = wl1273_fm_write_cmd(core, | 1433 | r = core->write(core, |
1576 | WL1273_MUTE_STATUS_SET, 0x0); | 1434 | WL1273_MUTE_STATUS_SET, 0x0); |
1577 | else if (core->mode == WL1273_MODE_TX && ctrl->val) | 1435 | else if (core->mode == WL1273_MODE_TX && ctrl->val) |
1578 | r = wl1273_fm_write_cmd(core, WL1273_MUTE, 1); | 1436 | r = core->write(core, WL1273_MUTE, 1); |
1579 | else if (core->mode == WL1273_MODE_TX) | 1437 | else if (core->mode == WL1273_MODE_TX) |
1580 | r = wl1273_fm_write_cmd(core, WL1273_MUTE, 0); | 1438 | r = core->write(core, WL1273_MUTE, 0); |
1581 | 1439 | ||
1582 | mutex_unlock(&core->lock); | 1440 | mutex_unlock(&core->lock); |
1583 | break; | 1441 | break; |
@@ -1672,7 +1530,7 @@ static int wl1273_fm_vidioc_g_tuner(struct file *file, void *priv, | |||
1672 | if (mutex_lock_interruptible(&core->lock)) | 1530 | if (mutex_lock_interruptible(&core->lock)) |
1673 | return -EINTR; | 1531 | return -EINTR; |
1674 | 1532 | ||
1675 | r = wl1273_fm_read_reg(core, WL1273_STEREO_GET, &val); | 1533 | r = core->read(core, WL1273_STEREO_GET, &val); |
1676 | if (r) | 1534 | if (r) |
1677 | goto out; | 1535 | goto out; |
1678 | 1536 | ||
@@ -1681,7 +1539,7 @@ static int wl1273_fm_vidioc_g_tuner(struct file *file, void *priv, | |||
1681 | else | 1539 | else |
1682 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO; | 1540 | tuner->rxsubchans = V4L2_TUNER_SUB_MONO; |
1683 | 1541 | ||
1684 | r = wl1273_fm_read_reg(core, WL1273_RSSI_LVL_GET, &val); | 1542 | r = core->read(core, WL1273_RSSI_LVL_GET, &val); |
1685 | if (r) | 1543 | if (r) |
1686 | goto out; | 1544 | goto out; |
1687 | 1545 | ||
@@ -1690,7 +1548,7 @@ static int wl1273_fm_vidioc_g_tuner(struct file *file, void *priv, | |||
1690 | 1548 | ||
1691 | tuner->afc = 0; | 1549 | tuner->afc = 0; |
1692 | 1550 | ||
1693 | r = wl1273_fm_read_reg(core, WL1273_RDS_SYNC_GET, &val); | 1551 | r = core->read(core, WL1273_RDS_SYNC_GET, &val); |
1694 | if (r) | 1552 | if (r) |
1695 | goto out; | 1553 | goto out; |
1696 | 1554 | ||
@@ -1736,8 +1594,7 @@ static int wl1273_fm_vidioc_s_tuner(struct file *file, void *priv, | |||
1736 | dev_warn(radio->dev, "%s: RDS fails: %d\n", __func__, r); | 1594 | dev_warn(radio->dev, "%s: RDS fails: %d\n", __func__, r); |
1737 | 1595 | ||
1738 | if (tuner->audmode == V4L2_TUNER_MODE_MONO) { | 1596 | if (tuner->audmode == V4L2_TUNER_MODE_MONO) { |
1739 | r = wl1273_fm_write_cmd(core, WL1273_MOST_MODE_SET, | 1597 | r = core->write(core, WL1273_MOST_MODE_SET, WL1273_RX_MONO); |
1740 | WL1273_RX_MONO); | ||
1741 | if (r < 0) { | 1598 | if (r < 0) { |
1742 | dev_warn(radio->dev, "%s: MOST_MODE fails: %d\n", | 1599 | dev_warn(radio->dev, "%s: MOST_MODE fails: %d\n", |
1743 | __func__, r); | 1600 | __func__, r); |
@@ -1745,8 +1602,7 @@ static int wl1273_fm_vidioc_s_tuner(struct file *file, void *priv, | |||
1745 | } | 1602 | } |
1746 | radio->stereo = false; | 1603 | radio->stereo = false; |
1747 | } else if (tuner->audmode == V4L2_TUNER_MODE_STEREO) { | 1604 | } else if (tuner->audmode == V4L2_TUNER_MODE_STEREO) { |
1748 | r = wl1273_fm_write_cmd(core, WL1273_MOST_MODE_SET, | 1605 | r = core->write(core, WL1273_MOST_MODE_SET, WL1273_RX_STEREO); |
1749 | WL1273_RX_STEREO); | ||
1750 | if (r < 0) { | 1606 | if (r < 0) { |
1751 | dev_warn(radio->dev, "%s: MOST_MODE fails: %d\n", | 1607 | dev_warn(radio->dev, "%s: MOST_MODE fails: %d\n", |
1752 | __func__, r); | 1608 | __func__, r); |
@@ -1885,10 +1741,10 @@ static int wl1273_fm_vidioc_s_modulator(struct file *file, void *priv, | |||
1885 | r = wl1273_fm_set_rds(radio, WL1273_RDS_OFF); | 1741 | r = wl1273_fm_set_rds(radio, WL1273_RDS_OFF); |
1886 | 1742 | ||
1887 | if (modulator->txsubchans & V4L2_TUNER_SUB_MONO) | 1743 | if (modulator->txsubchans & V4L2_TUNER_SUB_MONO) |
1888 | r = wl1273_fm_write_cmd(core, WL1273_MONO_SET, WL1273_TX_MONO); | 1744 | r = core->write(core, WL1273_MONO_SET, WL1273_TX_MONO); |
1889 | else | 1745 | else |
1890 | r = wl1273_fm_write_cmd(core, WL1273_MONO_SET, | 1746 | r = core->write(core, WL1273_MONO_SET, |
1891 | WL1273_RX_STEREO); | 1747 | WL1273_RX_STEREO); |
1892 | if (r < 0) | 1748 | if (r < 0) |
1893 | dev_warn(radio->dev, WL1273_FM_DRIVER_NAME | 1749 | dev_warn(radio->dev, WL1273_FM_DRIVER_NAME |
1894 | "MONO_SET fails: %d\n", r); | 1750 | "MONO_SET fails: %d\n", r); |
@@ -1923,7 +1779,7 @@ static int wl1273_fm_vidioc_g_modulator(struct file *file, void *priv, | |||
1923 | if (mutex_lock_interruptible(&core->lock)) | 1779 | if (mutex_lock_interruptible(&core->lock)) |
1924 | return -EINTR; | 1780 | return -EINTR; |
1925 | 1781 | ||
1926 | r = wl1273_fm_read_reg(core, WL1273_MONO_SET, &val); | 1782 | r = core->read(core, WL1273_MONO_SET, &val); |
1927 | if (r) | 1783 | if (r) |
1928 | goto out; | 1784 | goto out; |
1929 | 1785 | ||
@@ -1960,38 +1816,38 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv) | |||
1960 | return 0; | 1816 | return 0; |
1961 | } | 1817 | } |
1962 | 1818 | ||
1963 | r = wl1273_fm_read_reg(core, WL1273_ASIC_ID_GET, &val); | 1819 | r = core->read(core, WL1273_ASIC_ID_GET, &val); |
1964 | if (r) | 1820 | if (r) |
1965 | dev_err(dev, "%s: Get ASIC_ID fails.\n", __func__); | 1821 | dev_err(dev, "%s: Get ASIC_ID fails.\n", __func__); |
1966 | else | 1822 | else |
1967 | dev_info(dev, "ASIC_ID: 0x%04x\n", val); | 1823 | dev_info(dev, "ASIC_ID: 0x%04x\n", val); |
1968 | 1824 | ||
1969 | r = wl1273_fm_read_reg(core, WL1273_ASIC_VER_GET, &val); | 1825 | r = core->read(core, WL1273_ASIC_VER_GET, &val); |
1970 | if (r) | 1826 | if (r) |
1971 | dev_err(dev, "%s: Get ASIC_VER fails.\n", __func__); | 1827 | dev_err(dev, "%s: Get ASIC_VER fails.\n", __func__); |
1972 | else | 1828 | else |
1973 | dev_info(dev, "ASIC Version: 0x%04x\n", val); | 1829 | dev_info(dev, "ASIC Version: 0x%04x\n", val); |
1974 | 1830 | ||
1975 | r = wl1273_fm_read_reg(core, WL1273_FIRM_VER_GET, &val); | 1831 | r = core->read(core, WL1273_FIRM_VER_GET, &val); |
1976 | if (r) | 1832 | if (r) |
1977 | dev_err(dev, "%s: Get FIRM_VER fails.\n", __func__); | 1833 | dev_err(dev, "%s: Get FIRM_VER fails.\n", __func__); |
1978 | else | 1834 | else |
1979 | dev_info(dev, "FW version: %d(0x%04x)\n", val, val); | 1835 | dev_info(dev, "FW version: %d(0x%04x)\n", val, val); |
1980 | 1836 | ||
1981 | r = wl1273_fm_read_reg(core, WL1273_BAND_SET, &val); | 1837 | r = core->read(core, WL1273_BAND_SET, &val); |
1982 | if (r) | 1838 | if (r) |
1983 | dev_err(dev, "%s: Get BAND fails.\n", __func__); | 1839 | dev_err(dev, "%s: Get BAND fails.\n", __func__); |
1984 | else | 1840 | else |
1985 | dev_info(dev, "BAND: %d\n", val); | 1841 | dev_info(dev, "BAND: %d\n", val); |
1986 | 1842 | ||
1987 | if (core->mode == WL1273_MODE_TX) { | 1843 | if (core->mode == WL1273_MODE_TX) { |
1988 | r = wl1273_fm_read_reg(core, WL1273_PUPD_SET, &val); | 1844 | r = core->read(core, WL1273_PUPD_SET, &val); |
1989 | if (r) | 1845 | if (r) |
1990 | dev_err(dev, "%s: Get PUPD fails.\n", __func__); | 1846 | dev_err(dev, "%s: Get PUPD fails.\n", __func__); |
1991 | else | 1847 | else |
1992 | dev_info(dev, "PUPD: 0x%04x\n", val); | 1848 | dev_info(dev, "PUPD: 0x%04x\n", val); |
1993 | 1849 | ||
1994 | r = wl1273_fm_read_reg(core, WL1273_CHANL_SET, &val); | 1850 | r = core->read(core, WL1273_CHANL_SET, &val); |
1995 | if (r) | 1851 | if (r) |
1996 | dev_err(dev, "%s: Get CHANL fails.\n", __func__); | 1852 | dev_err(dev, "%s: Get CHANL fails.\n", __func__); |
1997 | else | 1853 | else |
@@ -1999,13 +1855,13 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv) | |||
1999 | } else if (core->mode == WL1273_MODE_RX) { | 1855 | } else if (core->mode == WL1273_MODE_RX) { |
2000 | int bf = radio->rangelow; | 1856 | int bf = radio->rangelow; |
2001 | 1857 | ||
2002 | r = wl1273_fm_read_reg(core, WL1273_FREQ_SET, &val); | 1858 | r = core->read(core, WL1273_FREQ_SET, &val); |
2003 | if (r) | 1859 | if (r) |
2004 | dev_err(dev, "%s: Get FREQ fails.\n", __func__); | 1860 | dev_err(dev, "%s: Get FREQ fails.\n", __func__); |
2005 | else | 1861 | else |
2006 | dev_info(dev, "RX Frequency: %dkHz\n", bf + val*50); | 1862 | dev_info(dev, "RX Frequency: %dkHz\n", bf + val*50); |
2007 | 1863 | ||
2008 | r = wl1273_fm_read_reg(core, WL1273_MOST_MODE_SET, &val); | 1864 | r = core->read(core, WL1273_MOST_MODE_SET, &val); |
2009 | if (r) | 1865 | if (r) |
2010 | dev_err(dev, "%s: Get MOST_MODE fails.\n", | 1866 | dev_err(dev, "%s: Get MOST_MODE fails.\n", |
2011 | __func__); | 1867 | __func__); |
@@ -2016,7 +1872,7 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv) | |||
2016 | else | 1872 | else |
2017 | dev_info(dev, "MOST_MODE: Unexpected value: %d\n", val); | 1873 | dev_info(dev, "MOST_MODE: Unexpected value: %d\n", val); |
2018 | 1874 | ||
2019 | r = wl1273_fm_read_reg(core, WL1273_MOST_BLEND_SET, &val); | 1875 | r = core->read(core, WL1273_MOST_BLEND_SET, &val); |
2020 | if (r) | 1876 | if (r) |
2021 | dev_err(dev, "%s: Get MOST_BLEND fails.\n", __func__); | 1877 | dev_err(dev, "%s: Get MOST_BLEND fails.\n", __func__); |
2022 | else if (val == 0) | 1878 | else if (val == 0) |
@@ -2027,7 +1883,7 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv) | |||
2027 | else | 1883 | else |
2028 | dev_info(dev, "MOST_BLEND: Unexpected val: %d\n", val); | 1884 | dev_info(dev, "MOST_BLEND: Unexpected val: %d\n", val); |
2029 | 1885 | ||
2030 | r = wl1273_fm_read_reg(core, WL1273_STEREO_GET, &val); | 1886 | r = core->read(core, WL1273_STEREO_GET, &val); |
2031 | if (r) | 1887 | if (r) |
2032 | dev_err(dev, "%s: Get STEREO fails.\n", __func__); | 1888 | dev_err(dev, "%s: Get STEREO fails.\n", __func__); |
2033 | else if (val == 0) | 1889 | else if (val == 0) |
@@ -2037,25 +1893,25 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv) | |||
2037 | else | 1893 | else |
2038 | dev_info(dev, "STEREO: Unexpected value: %d\n", val); | 1894 | dev_info(dev, "STEREO: Unexpected value: %d\n", val); |
2039 | 1895 | ||
2040 | r = wl1273_fm_read_reg(core, WL1273_RSSI_LVL_GET, &val); | 1896 | r = core->read(core, WL1273_RSSI_LVL_GET, &val); |
2041 | if (r) | 1897 | if (r) |
2042 | dev_err(dev, "%s: Get RSSI_LVL fails.\n", __func__); | 1898 | dev_err(dev, "%s: Get RSSI_LVL fails.\n", __func__); |
2043 | else | 1899 | else |
2044 | dev_info(dev, "RX signal strength: %d\n", (s16) val); | 1900 | dev_info(dev, "RX signal strength: %d\n", (s16) val); |
2045 | 1901 | ||
2046 | r = wl1273_fm_read_reg(core, WL1273_POWER_SET, &val); | 1902 | r = core->read(core, WL1273_POWER_SET, &val); |
2047 | if (r) | 1903 | if (r) |
2048 | dev_err(dev, "%s: Get POWER fails.\n", __func__); | 1904 | dev_err(dev, "%s: Get POWER fails.\n", __func__); |
2049 | else | 1905 | else |
2050 | dev_info(dev, "POWER: 0x%04x\n", val); | 1906 | dev_info(dev, "POWER: 0x%04x\n", val); |
2051 | 1907 | ||
2052 | r = wl1273_fm_read_reg(core, WL1273_INT_MASK_SET, &val); | 1908 | r = core->read(core, WL1273_INT_MASK_SET, &val); |
2053 | if (r) | 1909 | if (r) |
2054 | dev_err(dev, "%s: Get INT_MASK fails.\n", __func__); | 1910 | dev_err(dev, "%s: Get INT_MASK fails.\n", __func__); |
2055 | else | 1911 | else |
2056 | dev_info(dev, "INT_MASK: 0x%04x\n", val); | 1912 | dev_info(dev, "INT_MASK: 0x%04x\n", val); |
2057 | 1913 | ||
2058 | r = wl1273_fm_read_reg(core, WL1273_RDS_SYNC_GET, &val); | 1914 | r = core->read(core, WL1273_RDS_SYNC_GET, &val); |
2059 | if (r) | 1915 | if (r) |
2060 | dev_err(dev, "%s: Get RDS_SYNC fails.\n", | 1916 | dev_err(dev, "%s: Get RDS_SYNC fails.\n", |
2061 | __func__); | 1917 | __func__); |
@@ -2067,14 +1923,14 @@ static int wl1273_fm_vidioc_log_status(struct file *file, void *priv) | |||
2067 | else | 1923 | else |
2068 | dev_info(dev, "RDS_SYNC: Unexpected value: %d\n", val); | 1924 | dev_info(dev, "RDS_SYNC: Unexpected value: %d\n", val); |
2069 | 1925 | ||
2070 | r = wl1273_fm_read_reg(core, WL1273_I2S_MODE_CONFIG_SET, &val); | 1926 | r = core->read(core, WL1273_I2S_MODE_CONFIG_SET, &val); |
2071 | if (r) | 1927 | if (r) |
2072 | dev_err(dev, "%s: Get I2S_MODE_CONFIG fails.\n", | 1928 | dev_err(dev, "%s: Get I2S_MODE_CONFIG fails.\n", |
2073 | __func__); | 1929 | __func__); |
2074 | else | 1930 | else |
2075 | dev_info(dev, "I2S_MODE_CONFIG: 0x%04x\n", val); | 1931 | dev_info(dev, "I2S_MODE_CONFIG: 0x%04x\n", val); |
2076 | 1932 | ||
2077 | r = wl1273_fm_read_reg(core, WL1273_VOLUME_SET, &val); | 1933 | r = core->read(core, WL1273_VOLUME_SET, &val); |
2078 | if (r) | 1934 | if (r) |
2079 | dev_err(dev, "%s: Get VOLUME fails.\n", __func__); | 1935 | dev_err(dev, "%s: Get VOLUME fails.\n", __func__); |
2080 | else | 1936 | else |
@@ -2184,10 +2040,6 @@ static int __devinit wl1273_fm_radio_probe(struct platform_device *pdev) | |||
2184 | radio->stereo = true; | 2040 | radio->stereo = true; |
2185 | radio->bus_type = "I2C"; | 2041 | radio->bus_type = "I2C"; |
2186 | 2042 | ||
2187 | radio->core->write = wl1273_fm_write_cmd; | ||
2188 | radio->core->set_audio = wl1273_fm_set_audio; | ||
2189 | radio->core->set_volume = wl1273_fm_set_volume; | ||
2190 | |||
2191 | if (radio->core->pdata->request_resources) { | 2043 | if (radio->core->pdata->request_resources) { |
2192 | r = radio->core->pdata->request_resources(radio->core->client); | 2044 | r = radio->core->pdata->request_resources(radio->core->client); |
2193 | if (r) { | 2045 | if (r) { |