Date:2011-10-05 10:46:50 (8 years 11 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
2525 * - I2C address 0x11: random access
2626 * - I2C address 0x60: sequential access, TEA5767 compatible
2727 * 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.
2929 * Note that while there are many similarities, the register map of the RDA5807
3030 * differs from that of the RDA5800 in several essential places.
3131 */
...... 
4040#include <linux/slab.h>
4141#include <linux/types.h>
4242#include <linux/videodev2.h>
43#include <media/radio-rda5807.h>
4344#include <media/v4l2-ctrls.h>
4445#include <media/v4l2-dev.h>
4546#include <media/v4l2-ioctl.h>
...... 
354355static int __devinit rda5807_i2c_probe(struct i2c_client *client,
355356                       const struct i2c_device_id *id)
356357{
358    struct rda5807_platform_data *pdata = client->dev.platform_data;
357359    struct rda5807_driver *radio;
358    int chipid;
359360    int err;
361    u16 val;
360362
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;
365372    }
366    if ((chipid & 0xFF00) != 0x5800) {
373    val = err;
374    if ((val & 0xFF00) != 0x5800) {
367375        dev_warn(&client->dev, "Chip ID mismatch: "
368                       "expected 58xx, got %04X\n", chipid);
376                       "expected 58xx, got %04X\n", val);
369377        return -ENODEV;
370378    }
371379    dev_info(&client->dev, "Found FM radio receiver\n");
...... 
417425        goto err_ctrl_free;
418426    }
419427
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
420457    err = v4l2_ctrl_handler_setup(&radio->ctrl_handler);
421458    if (err < 0) {
422459        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
42struct rda5807_platform_data {
43    u8 input_flags;
44    u8 output_flags;
45};
46
47#endif /* RADIO_RDA5807_H */

Archive Download the corresponding diff file



interactive