Commit 966a1601 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

Merge branch 'topic/si476x' into patchwork

* topic/si476x:
  Revert "[media] mfd: Add chip properties handling code for SI476X MFD"
  Revert "[media] mfd: Add the main bulk of core driver for SI476x code"
  Revert "[media] mfd: Add commands abstraction layer for SI476X MFD"
  [media] v4l2: Add a V4L2 driver for SI476X MFD
parents cfc3d6c4 a9dc73e2
SI476x Driver Readme
------------------------------------------------
Copyright (C) 2013 Andrey Smirnov <andrew.smirnov@gmail.com>
TODO for the driver
------------------------------
- According to the SiLabs' datasheet it is possible to update the
firmware of the radio chip in the run-time, thus bringing it to the
most recent version. Unfortunately I couldn't find any mentioning of
the said firmware update for the old chips that I tested the driver
against, so for chips like that the driver only exposes the old
functionality.
Parameters exposed over debugfs
-------------------------------
SI476x allow user to get multiple characteristics that can be very
useful for EoL testing/RF performance estimation, parameters that have
very little to do with V4L2 subsystem. Such parameters are exposed via
debugfs and can be accessed via regular file I/O operations.
The drivers exposes following files:
* /sys/kernel/debug/<device-name>/acf
This file contains ACF(Automatically Controlled Features) status
information. The contents of the file is binary data of the
following layout:
Offset | Name | Description
====================================================================
0x00 | blend_int | Flag, set when stereo separation has
| | crossed below the blend threshold
--------------------------------------------------------------------
0x01 | hblend_int | Flag, set when HiBlend cutoff
| | frequency is lower than threshold
--------------------------------------------------------------------
0x02 | hicut_int | Flag, set when HiCut cutoff
| | frequency is lower than threshold
--------------------------------------------------------------------
0x03 | chbw_int | Flag, set when channel filter
| | bandwidth is less than threshold
--------------------------------------------------------------------
0x04 | softmute_int | Flag indicating that softmute
| | attenuation has increased above
| | softmute threshold
--------------------------------------------------------------------
0x05 | smute | 0 - Audio is not soft muted
| | 1 - Audio is soft muted
--------------------------------------------------------------------
0x06 | smattn | Soft mute attenuation level in dB
--------------------------------------------------------------------
0x07 | chbw | Channel filter bandwidth in kHz
--------------------------------------------------------------------
0x08 | hicut | HiCut cutoff frequency in units of
| | 100Hz
--------------------------------------------------------------------
0x09 | hiblend | HiBlend cutoff frequency in units
| | of 100 Hz
--------------------------------------------------------------------
0x10 | pilot | 0 - Stereo pilot is not present
| | 1 - Stereo pilot is present
--------------------------------------------------------------------
0x11 | stblend | Stereo blend in %
--------------------------------------------------------------------
* /sys/kernel/debug/<device-name>/rds_blckcnt
This file contains statistics about RDS receptions. It's binary data
has the following layout:
Offset | Name | Description
====================================================================
0x00 | expected | Number of expected RDS blocks
--------------------------------------------------------------------
0x02 | received | Number of received RDS blocks
--------------------------------------------------------------------
0x04 | uncorrectable | Number of uncorrectable RDS blocks
--------------------------------------------------------------------
* /sys/kernel/debug/<device-name>/agc
This file contains information about parameters pertaining to
AGC(Automatic Gain Control)
The layout is:
Offset | Name | Description
====================================================================
0x00 | mxhi | 0 - FM Mixer PD high threshold is
| | not tripped
| | 1 - FM Mixer PD high threshold is
| | tripped
--------------------------------------------------------------------
0x01 | mxlo | ditto for FM Mixer PD low
--------------------------------------------------------------------
0x02 | lnahi | ditto for FM LNA PD high
--------------------------------------------------------------------
0x03 | lnalo | ditto for FM LNA PD low
--------------------------------------------------------------------
0x04 | fmagc1 | FMAGC1 attenuator resistance
| | (see datasheet for more detail)
--------------------------------------------------------------------
0x05 | fmagc2 | ditto for FMAGC2
--------------------------------------------------------------------
0x06 | pgagain | PGA gain in dB
--------------------------------------------------------------------
0x07 | fmwblang | FM/WB LNA Gain in dB
--------------------------------------------------------------------
* /sys/kernel/debug/<device-name>/rsq
This file contains information about parameters pertaining to
RSQ(Received Signal Quality)
The layout is:
Offset | Name | Description
====================================================================
0x00 | multhint | 0 - multipath value has not crossed
| | the Multipath high threshold
| | 1 - multipath value has crossed
| | the Multipath high threshold
--------------------------------------------------------------------
0x01 | multlint | ditto for Multipath low threshold
--------------------------------------------------------------------
0x02 | snrhint | 0 - received signal's SNR has not
| | crossed high threshold
| | 1 - received signal's SNR has
| | crossed high threshold
--------------------------------------------------------------------
0x03 | snrlint | ditto for low threshold
--------------------------------------------------------------------
0x04 | rssihint | ditto for RSSI high threshold
--------------------------------------------------------------------
0x05 | rssilint | ditto for RSSI low threshold
--------------------------------------------------------------------
0x06 | bltf | Flag indicating if seek command
| | reached/wrapped seek band limit
--------------------------------------------------------------------
0x07 | snr_ready | Indicates that SNR metrics is ready
--------------------------------------------------------------------
0x08 | rssiready | ditto for RSSI metrics
--------------------------------------------------------------------
0x09 | injside | 0 - Low-side injection is being used
| | 1 - High-side injection is used
--------------------------------------------------------------------
0x10 | afcrl | Flag indicating if AFC rails
--------------------------------------------------------------------
0x11 | valid | Flag indicating if channel is valid
--------------------------------------------------------------------
0x12 | readfreq | Current tuned frequency
--------------------------------------------------------------------
0x14 | freqoff | Singed frequency offset in units of
| | 2ppm
--------------------------------------------------------------------
0x15 | rssi | Signed value of RSSI in dBuV
--------------------------------------------------------------------
0x16 | snr | Signed RF SNR in dB
--------------------------------------------------------------------
0x17 | issi | Signed Image Strength Signal
| | indicator
--------------------------------------------------------------------
0x18 | lassi | Signed Low side adjacent Channel
| | Strength indicator
--------------------------------------------------------------------
0x19 | hassi | ditto fpr High side
--------------------------------------------------------------------
0x20 | mult | Multipath indicator
--------------------------------------------------------------------
0x21 | dev | Frequency deviation
--------------------------------------------------------------------
0x24 | assi | Adjascent channel SSI
--------------------------------------------------------------------
0x25 | usn | Ultrasonic noise indicator
--------------------------------------------------------------------
0x26 | pilotdev | Pilot deviation in units of 100 Hz
--------------------------------------------------------------------
0x27 | rdsdev | ditto for RDS
--------------------------------------------------------------------
0x28 | assidev | ditto for ASSI
--------------------------------------------------------------------
0x29 | strongdev | Frequency deviation
--------------------------------------------------------------------
0x30 | rdspi | RDS PI code
--------------------------------------------------------------------
* /sys/kernel/debug/<device-name>/rsq_primary
This file contains information about parameters pertaining to
RSQ(Received Signal Quality) for primary tuner only. Layout is as
the one above.
...@@ -18,6 +18,22 @@ config RADIO_SI470X ...@@ -18,6 +18,22 @@ config RADIO_SI470X
source "drivers/media/radio/si470x/Kconfig" source "drivers/media/radio/si470x/Kconfig"
config RADIO_SI476X
tristate "Silicon Laboratories Si476x I2C FM Radio"
depends on I2C && VIDEO_V4L2
depends on MFD_SI476X_CORE
select SND_SOC_SI476X
---help---
Choose Y here if you have this FM radio chip.
In order to control your radio card, you will need to use programs
that are compatible with the Video For Linux 2 API. Information on
this API and pointers to "v4l2" programs may be found at
<file:Documentation/video4linux/API.html>.
To compile this driver as a module, choose M here: the
module will be called radio-si476x.
config USB_MR800 config USB_MR800
tristate "AverMedia MR 800 USB FM radio support" tristate "AverMedia MR 800 USB FM radio support"
depends on USB && VIDEO_V4L2 depends on USB && VIDEO_V4L2
......
...@@ -19,6 +19,7 @@ obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o ...@@ -19,6 +19,7 @@ obj-$(CONFIG_RADIO_GEMTEK) += radio-gemtek.o
obj-$(CONFIG_RADIO_TRUST) += radio-trust.o obj-$(CONFIG_RADIO_TRUST) += radio-trust.o
obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o obj-$(CONFIG_I2C_SI4713) += si4713-i2c.o
obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o obj-$(CONFIG_RADIO_SI4713) += radio-si4713.o
obj-$(CONFIG_RADIO_SI476X) += radio-si476x.o
obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o
obj-$(CONFIG_USB_DSBR) += dsbr100.o obj-$(CONFIG_USB_DSBR) += dsbr100.o
obj-$(CONFIG_RADIO_SI470X) += si470x/ obj-$(CONFIG_RADIO_SI470X) += si470x/
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*
* drivers/mfd/si476x-prop.c -- Subroutines to access
* properties of si476x chips
*
* Copyright (C) 2012 Innovative Converged Devices(ICD)
* Copyright (C) 2013 Andrey Smirnov
*
* Author: Andrey Smirnov <andrew.smirnov@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/module.h>
#include <media/si476x.h>
#include <linux/mfd/si476x-core.h>
struct si476x_property_range {
u16 low, high;
};
static bool si476x_core_element_is_in_array(u16 element,
const u16 array[],
size_t size)
{
int i;
for (i = 0; i < size; i++)
if (element == array[i])
return true;
return false;
}
static bool si476x_core_element_is_in_range(u16 element,
const struct si476x_property_range range[],
size_t size)
{
int i;
for (i = 0; i < size; i++)
if (element <= range[i].high && element >= range[i].low)
return true;
return false;
}
static bool si476x_core_is_valid_property_a10(struct si476x_core *core,
u16 property)
{
static const u16 valid_properties[] = {
0x0000,
0x0500, 0x0501,
0x0600,
0x0709, 0x070C, 0x070D, 0x70E, 0x710,
0x0718,
0x1207, 0x1208,
0x2007,
0x2300,
};
static const struct si476x_property_range valid_ranges[] = {
{ 0x0200, 0x0203 },
{ 0x0300, 0x0303 },
{ 0x0400, 0x0404 },
{ 0x0700, 0x0707 },
{ 0x1100, 0x1102 },
{ 0x1200, 0x1204 },
{ 0x1300, 0x1306 },
{ 0x2000, 0x2005 },
{ 0x2100, 0x2104 },
{ 0x2106, 0x2106 },
{ 0x2200, 0x220E },
{ 0x3100, 0x3104 },
{ 0x3207, 0x320F },
{ 0x3300, 0x3304 },
{ 0x3500, 0x3517 },
{ 0x3600, 0x3617 },
{ 0x3700, 0x3717 },
{ 0x4000, 0x4003 },
};
return si476x_core_element_is_in_range(property, valid_ranges,
ARRAY_SIZE(valid_ranges)) ||
si476x_core_element_is_in_array(property, valid_properties,
ARRAY_SIZE(valid_properties));
}
static bool si476x_core_is_valid_property_a20(struct si476x_core *core,
u16 property)
{
static const u16 valid_properties[] = {
0x071B,
0x1006,
0x2210,
0x3401,
};
static const struct si476x_property_range valid_ranges[] = {
{ 0x2215, 0x2219 },
};
return si476x_core_is_valid_property_a10(core, property) ||
si476x_core_element_is_in_range(property, valid_ranges,
ARRAY_SIZE(valid_ranges)) ||
si476x_core_element_is_in_array(property, valid_properties,
ARRAY_SIZE(valid_properties));
}
static bool si476x_core_is_valid_property_a30(struct si476x_core *core,
u16 property)
{
static const u16 valid_properties[] = {
0x071C, 0x071D,
0x1007, 0x1008,
0x220F, 0x2214,
0x2301,
0x3105, 0x3106,
0x3402,
};
static const struct si476x_property_range valid_ranges[] = {
{ 0x0405, 0x0411 },
{ 0x2008, 0x200B },
{ 0x2220, 0x2223 },
{ 0x3100, 0x3106 },
};
return si476x_core_is_valid_property_a20(core, property) ||
si476x_core_element_is_in_range(property, valid_ranges,
ARRAY_SIZE(valid_ranges)) ||
si476x_core_element_is_in_array(property, valid_properties,
ARRAY_SIZE(valid_properties));
}
typedef bool (*valid_property_pred_t) (struct si476x_core *, u16);
static bool si476x_core_is_valid_property(struct si476x_core *core,
u16 property)
{
static const valid_property_pred_t is_valid_property[] = {
[SI476X_REVISION_A10] = si476x_core_is_valid_property_a10,
[SI476X_REVISION_A20] = si476x_core_is_valid_property_a20,
[SI476X_REVISION_A30] = si476x_core_is_valid_property_a30,
};
BUG_ON(core->revision > SI476X_REVISION_A30 ||
core->revision == -1);
return is_valid_property[core->revision](core, property);
}
static bool si476x_core_is_readonly_property(struct si476x_core *core,
u16 property)
{
BUG_ON(core->revision > SI476X_REVISION_A30 ||
core->revision == -1);
switch (core->revision) {
case SI476X_REVISION_A10:
return (property == 0x3200);
case SI476X_REVISION_A20:
return (property == 0x1006 ||
property == 0x2210 ||
property == 0x3200);
case SI476X_REVISION_A30:
return false;
}
return false;
}
static bool si476x_core_regmap_readable_register(struct device *dev,
unsigned int reg)
{
struct i2c_client *client = to_i2c_client(dev);
struct si476x_core *core = i2c_get_clientdata(client);
return si476x_core_is_valid_property(core, (u16) reg);
}
static bool si476x_core_regmap_writable_register(struct device *dev,
unsigned int reg)
{
struct i2c_client *client = to_i2c_client(dev);
struct si476x_core *core = i2c_get_clientdata(client);
return si476x_core_is_valid_property(core, (u16) reg) &&
!si476x_core_is_readonly_property(core, (u16) reg);
}
static int si476x_core_regmap_write(void *context, unsigned int reg,
unsigned int val)
{
return si476x_core_cmd_set_property(context, reg, val);
}
static int si476x_core_regmap_read(void *context, unsigned int reg,
unsigned *val)
{
struct si476x_core *core = context;
int err;
err = si476x_core_cmd_get_property(core, reg);
if (err < 0)
return err;
*val = err;
return 0;
}
static const struct regmap_config si476x_regmap_config = {
.reg_bits = 16,
.val_bits = 16,
.max_register = 0x4003,
.writeable_reg = si476x_core_regmap_writable_register,
.readable_reg = si476x_core_regmap_readable_register,
.reg_read = si476x_core_regmap_read,
.reg_write = si476x_core_regmap_write,
.cache_type = REGCACHE_RBTREE,
};
struct regmap *devm_regmap_init_si476x(struct si476x_core *core)
{
return devm_regmap_init(&core->client->dev, NULL,
core, &si476x_regmap_config);
}
EXPORT_SYMBOL_GPL(devm_regmap_init_si476x);
/*
* include/media/si476x.h -- Common definitions for si476x driver
*
* Copyright (C) 2012 Innovative Converged Devices(ICD)
* Copyright (C) 2013 Andrey Smirnov
*
* Author: Andrey Smirnov <andrew.smirnov@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
*/
#ifndef SI476X_H
#define SI476X_H
#include <linux/types.h>
#include <linux/videodev2.h>
#include <linux/mfd/si476x-reports.h>
enum si476x_ctrl_id {
V4L2_CID_SI476X_RSSI_THRESHOLD = (V4L2_CID_USER_SI476X_BASE + 1),
V4L2_CID_SI476X_SNR_THRESHOLD = (V4L2_CID_USER_SI476X_BASE + 2),
V4L2_CID_SI476X_MAX_TUNE_ERROR = (V4L2_CID_USER_SI476X_BASE + 3),
V4L2_CID_SI476X_HARMONICS_COUNT = (V4L2_CID_USER_SI476X_BASE + 4),
V4L2_CID_SI476X_DIVERSITY_MODE = (V4L2_CID_USER_SI476X_BASE + 5),
V4L2_CID_SI476X_INTERCHIP_LINK = (V4L2_CID_USER_SI476X_BASE + 6),
};
#endif /* SI476X_H*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment