Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * Sony CXD2820R demodulator driver
0004  *
0005  * Copyright (C) 2010 Antti Palosaari <crope@iki.fi>
0006  */
0007 
0008 
0009 #ifndef CXD2820R_H
0010 #define CXD2820R_H
0011 
0012 #include <linux/dvb/frontend.h>
0013 
0014 #define CXD2820R_GPIO_D (0 << 0) /* disable */
0015 #define CXD2820R_GPIO_E (1 << 0) /* enable */
0016 #define CXD2820R_GPIO_O (0 << 1) /* output */
0017 #define CXD2820R_GPIO_I (1 << 1) /* input */
0018 #define CXD2820R_GPIO_L (0 << 2) /* output low */
0019 #define CXD2820R_GPIO_H (1 << 2) /* output high */
0020 
0021 #define CXD2820R_TS_SERIAL        0x08
0022 #define CXD2820R_TS_SERIAL_MSB    0x28
0023 #define CXD2820R_TS_PARALLEL      0x30
0024 #define CXD2820R_TS_PARALLEL_MSB  0x70
0025 
0026 /*
0027  * I2C address: 0x6c, 0x6d
0028  */
0029 
0030 /**
0031  * struct cxd2820r_platform_data - Platform data for the cxd2820r driver
0032  * @ts_mode: TS mode.
0033  * @ts_clk_inv: TS clock inverted.
0034  * @if_agc_polarity: IF AGC polarity.
0035  * @spec_inv: Input spectrum inverted.
0036  * @gpio_chip_base: GPIO.
0037  * @get_dvb_frontend: Get DVB frontend.
0038  */
0039 struct cxd2820r_platform_data {
0040     u8 ts_mode;
0041     bool ts_clk_inv;
0042     bool if_agc_polarity;
0043     bool spec_inv;
0044     int **gpio_chip_base;
0045 
0046     struct dvb_frontend* (*get_dvb_frontend)(struct i2c_client *);
0047 /* private: For legacy media attach wrapper. Do not set value. */
0048     bool attach_in_use;
0049 };
0050 
0051 /**
0052  * struct cxd2820r_config - configuration for cxd2020r demod
0053  *
0054  * @i2c_address: Demodulator I2C address. Driver determines DVB-C slave I2C
0055  *       address automatically from master address.
0056  *       Default: none, must set. Values: 0x6c, 0x6d.
0057  * @ts_mode:    TS output mode. Default: none, must set. Values: FIXME?
0058  * @ts_clock_inv: TS clock inverted. Default: 0. Values: 0, 1.
0059  * @if_agc_polarity: Default: 0. Values: 0, 1
0060  * @spec_inv:   Spectrum inversion. Default: 0. Values: 0, 1.
0061  */
0062 struct cxd2820r_config {
0063     /* Demodulator I2C address.
0064      * Driver determines DVB-C slave I2C address automatically from master
0065      * address.
0066      * Default: none, must set
0067      * Values: 0x6c, 0x6d
0068      */
0069     u8 i2c_address;
0070 
0071     /* TS output mode.
0072      * Default: none, must set.
0073      * Values:
0074      */
0075     u8 ts_mode;
0076 
0077     /* TS clock inverted.
0078      * Default: 0
0079      * Values: 0, 1
0080      */
0081     bool ts_clock_inv;
0082 
0083     /* IF AGC polarity.
0084      * Default: 0
0085      * Values: 0, 1
0086      */
0087     bool if_agc_polarity;
0088 
0089     /* Spectrum inversion.
0090      * Default: 0
0091      * Values: 0, 1
0092      */
0093     bool spec_inv;
0094 };
0095 
0096 
0097 #if IS_REACHABLE(CONFIG_DVB_CXD2820R)
0098 /**
0099  * cxd2820r_attach - Attach a cxd2820r demod
0100  *
0101  * @config: pointer to &struct cxd2820r_config with demod configuration.
0102  * @i2c: i2c adapter to use.
0103  * @gpio_chip_base: if zero, disables GPIO setting. Otherwise, if
0104  *          CONFIG_GPIOLIB is set dynamically allocate
0105  *          gpio base; if is not set, use its value to
0106  *          setup the GPIO pins.
0107  *
0108  * return: FE pointer on success, NULL on failure.
0109  */
0110 extern struct dvb_frontend *cxd2820r_attach(
0111     const struct cxd2820r_config *config,
0112     struct i2c_adapter *i2c,
0113     int *gpio_chip_base
0114 );
0115 #else
0116 static inline struct dvb_frontend *cxd2820r_attach(
0117     const struct cxd2820r_config *config,
0118     struct i2c_adapter *i2c,
0119     int *gpio_chip_base
0120 )
0121 {
0122     printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
0123     return NULL;
0124 }
0125 
0126 #endif
0127 
0128 #endif /* CXD2820R_H */