1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * helene.h
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Sony HELENE DVB-S/S2/T/T2/C/C2/ISDB-T/S tuner driver (CXD2858ER)
6*4882a593Smuzhiyun *
7*4882a593Smuzhiyun * Copyright 2012 Sony Corporation
8*4882a593Smuzhiyun * Copyright (C) 2014 NetUP Inc.
9*4882a593Smuzhiyun * Copyright (C) 2014 Abylay Ospan <aospan@netup.ru>
10*4882a593Smuzhiyun */
11*4882a593Smuzhiyun
12*4882a593Smuzhiyun #ifndef __DVB_HELENE_H__
13*4882a593Smuzhiyun #define __DVB_HELENE_H__
14*4882a593Smuzhiyun
15*4882a593Smuzhiyun #include <linux/dvb/frontend.h>
16*4882a593Smuzhiyun #include <linux/i2c.h>
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun enum helene_xtal {
19*4882a593Smuzhiyun SONY_HELENE_XTAL_16000, /* 16 MHz */
20*4882a593Smuzhiyun SONY_HELENE_XTAL_20500, /* 20.5 MHz */
21*4882a593Smuzhiyun SONY_HELENE_XTAL_24000, /* 24 MHz */
22*4882a593Smuzhiyun SONY_HELENE_XTAL_41000 /* 41 MHz */
23*4882a593Smuzhiyun };
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun /**
26*4882a593Smuzhiyun * struct helene_config - the configuration of 'Helene' tuner driver
27*4882a593Smuzhiyun * @i2c_address: I2C address of the tuner
28*4882a593Smuzhiyun * @xtal_freq_mhz: Oscillator frequency, MHz
29*4882a593Smuzhiyun * @set_tuner_priv: Callback function private context
30*4882a593Smuzhiyun * @set_tuner_callback: Callback function that notifies the parent driver
31*4882a593Smuzhiyun * which tuner is active now
32*4882a593Smuzhiyun * @xtal: Cristal frequency as described by &enum helene_xtal
33*4882a593Smuzhiyun * @fe: Frontend for which connects this tuner
34*4882a593Smuzhiyun */
35*4882a593Smuzhiyun struct helene_config {
36*4882a593Smuzhiyun u8 i2c_address;
37*4882a593Smuzhiyun u8 xtal_freq_mhz;
38*4882a593Smuzhiyun void *set_tuner_priv;
39*4882a593Smuzhiyun int (*set_tuner_callback)(void *, int);
40*4882a593Smuzhiyun enum helene_xtal xtal;
41*4882a593Smuzhiyun
42*4882a593Smuzhiyun struct dvb_frontend *fe;
43*4882a593Smuzhiyun };
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun #if IS_REACHABLE(CONFIG_DVB_HELENE)
46*4882a593Smuzhiyun /**
47*4882a593Smuzhiyun * Attach a helene tuner (terrestrial and cable standards)
48*4882a593Smuzhiyun *
49*4882a593Smuzhiyun * @fe: frontend to be attached
50*4882a593Smuzhiyun * @config: pointer to &struct helene_config with tuner configuration.
51*4882a593Smuzhiyun * @i2c: i2c adapter to use.
52*4882a593Smuzhiyun *
53*4882a593Smuzhiyun * return: FE pointer on success, NULL on failure.
54*4882a593Smuzhiyun */
55*4882a593Smuzhiyun extern struct dvb_frontend *helene_attach(struct dvb_frontend *fe,
56*4882a593Smuzhiyun const struct helene_config *config,
57*4882a593Smuzhiyun struct i2c_adapter *i2c);
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun /**
60*4882a593Smuzhiyun * Attach a helene tuner (satellite standards)
61*4882a593Smuzhiyun *
62*4882a593Smuzhiyun * @fe: frontend to be attached
63*4882a593Smuzhiyun * @config: pointer to &struct helene_config with tuner configuration.
64*4882a593Smuzhiyun * @i2c: i2c adapter to use.
65*4882a593Smuzhiyun *
66*4882a593Smuzhiyun * return: FE pointer on success, NULL on failure.
67*4882a593Smuzhiyun */
68*4882a593Smuzhiyun extern struct dvb_frontend *helene_attach_s(struct dvb_frontend *fe,
69*4882a593Smuzhiyun const struct helene_config *config,
70*4882a593Smuzhiyun struct i2c_adapter *i2c);
71*4882a593Smuzhiyun #else
helene_attach(struct dvb_frontend * fe,const struct helene_config * config,struct i2c_adapter * i2c)72*4882a593Smuzhiyun static inline struct dvb_frontend *helene_attach(struct dvb_frontend *fe,
73*4882a593Smuzhiyun const struct helene_config *config,
74*4882a593Smuzhiyun struct i2c_adapter *i2c)
75*4882a593Smuzhiyun {
76*4882a593Smuzhiyun pr_warn("%s: driver disabled by Kconfig\n", __func__);
77*4882a593Smuzhiyun return NULL;
78*4882a593Smuzhiyun }
helene_attach_s(struct dvb_frontend * fe,const struct helene_config * config,struct i2c_adapter * i2c)79*4882a593Smuzhiyun static inline struct dvb_frontend *helene_attach_s(struct dvb_frontend *fe,
80*4882a593Smuzhiyun const struct helene_config *config,
81*4882a593Smuzhiyun struct i2c_adapter *i2c)
82*4882a593Smuzhiyun {
83*4882a593Smuzhiyun pr_warn("%s: driver disabled by Kconfig\n", __func__);
84*4882a593Smuzhiyun return NULL;
85*4882a593Smuzhiyun }
86*4882a593Smuzhiyun #endif
87*4882a593Smuzhiyun
88*4882a593Smuzhiyun #endif
89