Date: | 2011-10-05 10:46:50 (12 years 5 months ago) |
---|---|
Author: | Maarten ter Huurne |
Commit: | 9034541087beff46bc666fb285015a1cbf292888 |
Message: | media: radio: RDA5807: Configure inputs and outputs using platform
data. |
Files: |
drivers/media/radio/radio-rda5807.c (4 diffs) include/media/radio-rda5807.h (1 diff) |
Change Details
drivers/media/radio/radio-rda5807.c | ||
---|---|---|
25 | 25 | * - I2C address 0x11: random access |
26 | 26 | * - I2C address 0x60: sequential access, TEA5767 compatible |
27 | 27 | * This driver uses random access and therefore the i2c_board_info should |
28 | * specify address 0x11. | |
28 | * specify address 0x11 using the macro RDA5807_I2C_ADDR. | |
29 | 29 | * Note that while there are many similarities, the register map of the RDA5807 |
30 | 30 | * differs from that of the RDA5800 in several essential places. |
31 | 31 | */ |
... | ... | |
40 | 40 | #include <linux/slab.h> |
41 | 41 | #include <linux/types.h> |
42 | 42 | #include <linux/videodev2.h> |
43 | #include <media/radio-rda5807.h> | |
43 | 44 | #include <media/v4l2-ctrls.h> |
44 | 45 | #include <media/v4l2-dev.h> |
45 | 46 | #include <media/v4l2-ioctl.h> |
... | ... | |
354 | 355 | static int __devinit rda5807_i2c_probe(struct i2c_client *client, |
355 | 356 | const struct i2c_device_id *id) |
356 | 357 | { |
358 | struct rda5807_platform_data *pdata = client->dev.platform_data; | |
357 | 359 | struct rda5807_driver *radio; |
358 | int chipid; | |
359 | 360 | int err; |
361 | u16 val; | |
360 | 362 | |
361 | chipid = rda5807_i2c_read(client, RDA5807_REG_CHIPID); | |
362 | if (chipid < 0) { | |
363 | dev_warn(&client->dev, "Failed to read chip ID (%d)\n", chipid); | |
364 | return chipid; | |
363 | if (!pdata) { | |
364 | dev_warn(&client->dev, "Platform data missing\n"); | |
365 | return -EINVAL; | |
366 | } | |
367 | ||
368 | err = rda5807_i2c_read(client, RDA5807_REG_CHIPID); | |
369 | if (err < 0) { | |
370 | dev_warn(&client->dev, "Failed to read chip ID (%d)\n", err); | |
371 | return err; | |
365 | 372 | } |
366 | if ((chipid & 0xFF00) != 0x5800) { | |
373 | val = err; | |
374 | if ((val & 0xFF00) != 0x5800) { | |
367 | 375 | dev_warn(&client->dev, "Chip ID mismatch: " |
368 | "expected 58xx, got %04X\n", chipid); | |
376 | "expected 58xx, got %04X\n", val); | |
369 | 377 | return -ENODEV; |
370 | 378 | } |
371 | 379 | dev_info(&client->dev, "Found FM radio receiver\n"); |
... | ... | |
417 | 425 | goto err_ctrl_free; |
418 | 426 | } |
419 | 427 | |
428 | /* Configure chip inputs. */ | |
429 | err = rda5807_update_reg(radio, RDA5807_REG_INTM_THRESH_VOL, | |
430 | 0xF << 4, (pdata->input_flags & 0xF) << 4); | |
431 | if (err < 0) { | |
432 | dev_warn(&client->dev, "Failed to configure inputs (%d)\n", | |
433 | err); | |
434 | } | |
435 | /* Configure chip outputs. */ | |
436 | val = 0; | |
437 | if (pdata->output_flags & RDA5807_OUTPUT_AUDIO_I2S) { | |
438 | val |= BIT(6); | |
439 | } else if (pdata->output_flags & RDA5807_OUTPUT_STEREO_INDICATOR) { | |
440 | val |= BIT(4); | |
441 | } | |
442 | err = rda5807_update_reg(radio, RDA5807_REG_IOCFG, 0x003F, val); | |
443 | if (err < 0) { | |
444 | dev_warn(&client->dev, "Failed to configure outputs (%d)\n", | |
445 | err); | |
446 | } | |
447 | val = 0; | |
448 | if (pdata->output_flags & RDA5807_OUTPUT_AUDIO_ANALOG) { | |
449 | val |= BIT(15); | |
450 | } | |
451 | err = rda5807_update_reg(radio, RDA5807_REG_CTRL, BIT(15), val); | |
452 | if (err < 0) { | |
453 | dev_warn(&client->dev, "Failed to configure outputs (%d)\n", | |
454 | err); | |
455 | } | |
456 | ||
420 | 457 | err = v4l2_ctrl_handler_setup(&radio->ctrl_handler); |
421 | 458 | if (err < 0) { |
422 | 459 | dev_warn(&client->dev, "Failed to set default control values" |
include/media/radio-rda5807.h | ||
---|---|---|
1 | /* | |
2 | * radio-rda5807.h - Board related data for the RDA5807 FM tuner chip driver | |
3 | * | |
4 | * Copyright (c) 2011 Maarten ter Huurne <maarten@treewalker.org> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License version 2 as | |
8 | * published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, write to the Free Software | |
17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
18 | */ | |
19 | ||
20 | #ifndef RADIO_RDA5807_H | |
21 | #define RADIO_RDA5807_H | |
22 | ||
23 | /* The driver uses random access I/O to the registers via I2C address 0x11. */ | |
24 | #define RDA5807_I2C_ADDR 0x11 | |
25 | ||
26 | /* Working current: 1.8, 2.1, 2.5 or 3.0 mA. */ | |
27 | #define RDA5807_INPUT_LNA_WC_18 (0 << 0) | |
28 | #define RDA5807_INPUT_LNA_WC_21 (1 << 0) | |
29 | #define RDA5807_INPUT_LNA_WC_25 (2 << 0) | |
30 | #define RDA5807_INPUT_LNA_WC_30 (3 << 0) | |
31 | /* Use antenna signal connected to LNAN and/or LNAP pin? */ | |
32 | #define RDA5807_LNA_PORT_N (1 << 2) | |
33 | #define RDA5807_LNA_PORT_P (1 << 3) | |
34 | ||
35 | /* Ouput analog audio on LOUT+ROUT pins */ | |
36 | #define RDA5807_OUTPUT_AUDIO_ANALOG (1 << 0) | |
37 | /* Output digital audio using I2S on GPIO1-3 pins */ | |
38 | #define RDA5807_OUTPUT_AUDIO_I2S (1 << 1) | |
39 | /* Output stereo indicator signal on GPIO3 pin */ | |
40 | #define RDA5807_OUTPUT_STEREO_INDICATOR (1 << 2) | |
41 | ||
42 | struct rda5807_platform_data { | |
43 | u8 input_flags; | |
44 | u8 output_flags; | |
45 | }; | |
46 | ||
47 | #endif /* RADIO_RDA5807_H */ |
Branches:
ben-wpan
ben-wpan-stefan
5396a9238205f20f811ea57898980d3ca82df0b6
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9