linux/drivers/media/radio/si4713/si4713.h
<<
>>
Prefs
   1/*
   2 * drivers/media/radio/si4713-i2c.h
   3 *
   4 * Property and commands definitions for Si4713 radio transmitter chip.
   5 *
   6 * Copyright (c) 2008 Instituto Nokia de Tecnologia - INdT
   7 * Contact: Eduardo Valentin <eduardo.valentin@nokia.com>
   8 *
   9 * This file is licensed under the terms of the GNU General Public License
  10 * version 2. This program is licensed "as is" without any warranty of any
  11 * kind, whether express or implied.
  12 *
  13 */
  14
  15#ifndef SI4713_I2C_H
  16#define SI4713_I2C_H
  17
  18#include <linux/regulator/consumer.h>
  19#include <media/v4l2-subdev.h>
  20#include <media/v4l2-ctrls.h>
  21#include <media/si4713.h>
  22
  23#define SI4713_PRODUCT_NUMBER           0x0D
  24
  25/* Command Timeouts */
  26#define DEFAULT_TIMEOUT                 500
  27#define TIMEOUT_SET_PROPERTY            20
  28#define TIMEOUT_TX_TUNE_POWER           30000
  29#define TIMEOUT_TX_TUNE                 110000
  30#define TIMEOUT_POWER_UP                200000
  31
  32/*
  33 * Command and its arguments definitions
  34 */
  35#define SI4713_PWUP_CTSIEN              (1<<7)
  36#define SI4713_PWUP_GPO2OEN             (1<<6)
  37#define SI4713_PWUP_PATCH               (1<<5)
  38#define SI4713_PWUP_XOSCEN              (1<<4)
  39#define SI4713_PWUP_FUNC_TX             0x02
  40#define SI4713_PWUP_FUNC_PATCH          0x0F
  41#define SI4713_PWUP_OPMOD_ANALOG        0x50
  42#define SI4713_PWUP_OPMOD_DIGITAL       0x0F
  43#define SI4713_PWUP_NARGS               2
  44#define SI4713_PWUP_NRESP               1
  45#define SI4713_CMD_POWER_UP             0x01
  46
  47#define SI4713_GETREV_NRESP             9
  48#define SI4713_CMD_GET_REV              0x10
  49
  50#define SI4713_PWDN_NRESP               1
  51#define SI4713_CMD_POWER_DOWN           0x11
  52
  53#define SI4713_SET_PROP_NARGS           5
  54#define SI4713_SET_PROP_NRESP           1
  55#define SI4713_CMD_SET_PROPERTY         0x12
  56
  57#define SI4713_GET_PROP_NARGS           3
  58#define SI4713_GET_PROP_NRESP           4
  59#define SI4713_CMD_GET_PROPERTY         0x13
  60
  61#define SI4713_GET_STATUS_NRESP         1
  62#define SI4713_CMD_GET_INT_STATUS       0x14
  63
  64#define SI4713_CMD_PATCH_ARGS           0x15
  65#define SI4713_CMD_PATCH_DATA           0x16
  66
  67#define SI4713_MAX_FREQ                 10800
  68#define SI4713_MIN_FREQ                 7600
  69#define SI4713_TXFREQ_NARGS             3
  70#define SI4713_TXFREQ_NRESP             1
  71#define SI4713_CMD_TX_TUNE_FREQ         0x30
  72
  73#define SI4713_MAX_POWER                120
  74#define SI4713_MIN_POWER                88
  75#define SI4713_MAX_ANTCAP               191
  76#define SI4713_MIN_ANTCAP               0
  77#define SI4713_TXPWR_NARGS              4
  78#define SI4713_TXPWR_NRESP              1
  79#define SI4713_CMD_TX_TUNE_POWER        0x31
  80
  81#define SI4713_TXMEA_NARGS              4
  82#define SI4713_TXMEA_NRESP              1
  83#define SI4713_CMD_TX_TUNE_MEASURE      0x32
  84
  85#define SI4713_INTACK_MASK              0x01
  86#define SI4713_TXSTATUS_NARGS           1
  87#define SI4713_TXSTATUS_NRESP           8
  88#define SI4713_CMD_TX_TUNE_STATUS       0x33
  89
  90#define SI4713_OVERMOD_BIT              (1 << 2)
  91#define SI4713_IALH_BIT                 (1 << 1)
  92#define SI4713_IALL_BIT                 (1 << 0)
  93#define SI4713_ASQSTATUS_NARGS          1
  94#define SI4713_ASQSTATUS_NRESP          5
  95#define SI4713_CMD_TX_ASQ_STATUS        0x34
  96
  97#define SI4713_RDSBUFF_MODE_MASK        0x87
  98#define SI4713_RDSBUFF_NARGS            7
  99#define SI4713_RDSBUFF_NRESP            6
 100#define SI4713_CMD_TX_RDS_BUFF          0x35
 101
 102#define SI4713_RDSPS_PSID_MASK          0x1F
 103#define SI4713_RDSPS_NARGS              5
 104#define SI4713_RDSPS_NRESP              1
 105#define SI4713_CMD_TX_RDS_PS            0x36
 106
 107#define SI4713_CMD_GPO_CTL              0x80
 108#define SI4713_CMD_GPO_SET              0x81
 109
 110/*
 111 * Bits from status response
 112 */
 113#define SI4713_CTS                      (1<<7)
 114#define SI4713_ERR                      (1<<6)
 115#define SI4713_RDS_INT                  (1<<2)
 116#define SI4713_ASQ_INT                  (1<<1)
 117#define SI4713_STC_INT                  (1<<0)
 118
 119/*
 120 * Property definitions
 121 */
 122#define SI4713_GPO_IEN                  0x0001
 123#define SI4713_DIG_INPUT_FORMAT         0x0101
 124#define SI4713_DIG_INPUT_SAMPLE_RATE    0x0103
 125#define SI4713_REFCLK_FREQ              0x0201
 126#define SI4713_REFCLK_PRESCALE          0x0202
 127#define SI4713_TX_COMPONENT_ENABLE      0x2100
 128#define SI4713_TX_AUDIO_DEVIATION       0x2101
 129#define SI4713_TX_PILOT_DEVIATION       0x2102
 130#define SI4713_TX_RDS_DEVIATION         0x2103
 131#define SI4713_TX_LINE_INPUT_LEVEL      0x2104
 132#define SI4713_TX_LINE_INPUT_MUTE       0x2105
 133#define SI4713_TX_PREEMPHASIS           0x2106
 134#define SI4713_TX_PILOT_FREQUENCY       0x2107
 135#define SI4713_TX_ACOMP_ENABLE          0x2200
 136#define SI4713_TX_ACOMP_THRESHOLD       0x2201
 137#define SI4713_TX_ACOMP_ATTACK_TIME     0x2202
 138#define SI4713_TX_ACOMP_RELEASE_TIME    0x2203
 139#define SI4713_TX_ACOMP_GAIN            0x2204
 140#define SI4713_TX_LIMITER_RELEASE_TIME  0x2205
 141#define SI4713_TX_ASQ_INTERRUPT_SOURCE  0x2300
 142#define SI4713_TX_ASQ_LEVEL_LOW         0x2301
 143#define SI4713_TX_ASQ_DURATION_LOW      0x2302
 144#define SI4713_TX_ASQ_LEVEL_HIGH        0x2303
 145#define SI4713_TX_ASQ_DURATION_HIGH     0x2304
 146#define SI4713_TX_RDS_INTERRUPT_SOURCE  0x2C00
 147#define SI4713_TX_RDS_PI                0x2C01
 148#define SI4713_TX_RDS_PS_MIX            0x2C02
 149#define SI4713_TX_RDS_PS_MISC           0x2C03
 150#define SI4713_TX_RDS_PS_REPEAT_COUNT   0x2C04
 151#define SI4713_TX_RDS_PS_MESSAGE_COUNT  0x2C05
 152#define SI4713_TX_RDS_PS_AF             0x2C06
 153#define SI4713_TX_RDS_FIFO_SIZE         0x2C07
 154
 155#define PREEMPHASIS_USA                 75
 156#define PREEMPHASIS_EU                  50
 157#define PREEMPHASIS_DISABLED            0
 158#define FMPE_USA                        0x00
 159#define FMPE_EU                         0x01
 160#define FMPE_DISABLED                   0x02
 161
 162#define POWER_UP                        0x01
 163#define POWER_DOWN                      0x00
 164
 165#define MAX_RDS_PTY                     31
 166#define MAX_RDS_DEVIATION               90000
 167
 168/*
 169 * PSNAME is known to be defined as 8 character sized (RDS Spec).
 170 * However, there is receivers which scroll PSNAME 8xN sized.
 171 */
 172#define MAX_RDS_PS_NAME                 96
 173
 174/*
 175 * MAX_RDS_RADIO_TEXT is known to be defined as 32 (2A group) or 64 (2B group)
 176 * character sized (RDS Spec).
 177 * However, there is receivers which scroll them as well.
 178 */
 179#define MAX_RDS_RADIO_TEXT              384
 180
 181#define MAX_LIMITER_RELEASE_TIME        102390
 182#define MAX_LIMITER_DEVIATION           90000
 183
 184#define MAX_PILOT_DEVIATION             90000
 185#define MAX_PILOT_FREQUENCY             19000
 186
 187#define MAX_ACOMP_RELEASE_TIME          1000000
 188#define MAX_ACOMP_ATTACK_TIME           5000
 189#define MAX_ACOMP_THRESHOLD             0
 190#define MIN_ACOMP_THRESHOLD             (-40)
 191#define MAX_ACOMP_GAIN                  20
 192
 193#define SI4713_NUM_SUPPLIES             2
 194
 195/*
 196 * si4713_device - private data
 197 */
 198struct si4713_device {
 199        /* v4l2_subdev and i2c reference (v4l2_subdev priv data) */
 200        struct v4l2_subdev sd;
 201        struct v4l2_ctrl_handler ctrl_handler;
 202        /* private data structures */
 203        struct { /* si4713 control cluster */
 204                /* This is one big cluster since the mute control
 205                 * powers off the device and after unmuting again all
 206                 * controls need to be set at once. The only way of doing
 207                 * that is by making it one big cluster. */
 208                struct v4l2_ctrl *mute;
 209                struct v4l2_ctrl *rds_ps_name;
 210                struct v4l2_ctrl *rds_radio_text;
 211                struct v4l2_ctrl *rds_pi;
 212                struct v4l2_ctrl *rds_deviation;
 213                struct v4l2_ctrl *rds_pty;
 214                struct v4l2_ctrl *rds_compressed;
 215                struct v4l2_ctrl *rds_art_head;
 216                struct v4l2_ctrl *rds_stereo;
 217                struct v4l2_ctrl *rds_ta;
 218                struct v4l2_ctrl *rds_tp;
 219                struct v4l2_ctrl *rds_ms;
 220                struct v4l2_ctrl *rds_dyn_pty;
 221                struct v4l2_ctrl *rds_alt_freqs_enable;
 222                struct v4l2_ctrl *rds_alt_freqs;
 223                struct v4l2_ctrl *compression_enabled;
 224                struct v4l2_ctrl *compression_threshold;
 225                struct v4l2_ctrl *compression_gain;
 226                struct v4l2_ctrl *compression_attack_time;
 227                struct v4l2_ctrl *compression_release_time;
 228                struct v4l2_ctrl *pilot_tone_enabled;
 229                struct v4l2_ctrl *pilot_tone_freq;
 230                struct v4l2_ctrl *pilot_tone_deviation;
 231                struct v4l2_ctrl *limiter_enabled;
 232                struct v4l2_ctrl *limiter_deviation;
 233                struct v4l2_ctrl *limiter_release_time;
 234                struct v4l2_ctrl *tune_preemphasis;
 235                struct v4l2_ctrl *tune_pwr_level;
 236                struct v4l2_ctrl *tune_ant_cap;
 237        };
 238        struct completion work;
 239        unsigned supplies;
 240        struct regulator_bulk_data supply_data[SI4713_NUM_SUPPLIES];
 241        int gpio_reset;
 242        u32 power_state;
 243        u32 rds_enabled;
 244        u32 frequency;
 245        u32 preemphasis;
 246        u32 stereo;
 247        u32 tune_rnl;
 248};
 249#endif /* ifndef SI4713_I2C_H */
 250