18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  Samsung s5h1432 VSB/QAM demodulator driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (C) 2009 Bill Liu <Bill.Liu@Conexant.com>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef __S5H1432_H__
98c2ecf20Sopenharmony_ci#define __S5H1432_H__
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include <linux/dvb/frontend.h>
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define S5H1432_I2C_TOP_ADDR (0x02 >> 1)
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define TAIWAN_HI_IF_FREQ_44_MHZ 44000000
168c2ecf20Sopenharmony_ci#define EUROPE_HI_IF_FREQ_36_MHZ 36000000
178c2ecf20Sopenharmony_ci#define IF_FREQ_6_MHZ             6000000
188c2ecf20Sopenharmony_ci#define IF_FREQ_3point3_MHZ       3300000
198c2ecf20Sopenharmony_ci#define IF_FREQ_3point5_MHZ       3500000
208c2ecf20Sopenharmony_ci#define IF_FREQ_4_MHZ             4000000
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistruct s5h1432_config {
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci	/* serial/parallel output */
258c2ecf20Sopenharmony_ci#define S5H1432_PARALLEL_OUTPUT 0
268c2ecf20Sopenharmony_ci#define S5H1432_SERIAL_OUTPUT   1
278c2ecf20Sopenharmony_ci	u8 output_mode;
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci	/* GPIO Setting */
308c2ecf20Sopenharmony_ci#define S5H1432_GPIO_OFF 0
318c2ecf20Sopenharmony_ci#define S5H1432_GPIO_ON  1
328c2ecf20Sopenharmony_ci	u8 gpio;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	/* MPEG signal timing */
358c2ecf20Sopenharmony_ci#define S5H1432_MPEGTIMING_CONTINUOUS_INVERTING_CLOCK       0
368c2ecf20Sopenharmony_ci#define S5H1432_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK    1
378c2ecf20Sopenharmony_ci#define S5H1432_MPEGTIMING_NONCONTINUOUS_INVERTING_CLOCK    2
388c2ecf20Sopenharmony_ci#define S5H1432_MPEGTIMING_NONCONTINUOUS_NONINVERTING_CLOCK 3
398c2ecf20Sopenharmony_ci	u16 mpeg_timing;
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	/* IF Freq for QAM and VSB in KHz */
428c2ecf20Sopenharmony_ci#define S5H1432_IF_3250  3250
438c2ecf20Sopenharmony_ci#define S5H1432_IF_3500  3500
448c2ecf20Sopenharmony_ci#define S5H1432_IF_4000  4000
458c2ecf20Sopenharmony_ci#define S5H1432_IF_5380  5380
468c2ecf20Sopenharmony_ci#define S5H1432_IF_44000 44000
478c2ecf20Sopenharmony_ci#define S5H1432_VSB_IF_DEFAULT s5h1432_IF_44000
488c2ecf20Sopenharmony_ci#define S5H1432_QAM_IF_DEFAULT s5h1432_IF_44000
498c2ecf20Sopenharmony_ci	u16 qam_if;
508c2ecf20Sopenharmony_ci	u16 vsb_if;
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	/* Spectral Inversion */
538c2ecf20Sopenharmony_ci#define S5H1432_INVERSION_OFF 0
548c2ecf20Sopenharmony_ci#define S5H1432_INVERSION_ON  1
558c2ecf20Sopenharmony_ci	u8 inversion;
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci	/* Return lock status based on tuner lock, or demod lock */
588c2ecf20Sopenharmony_ci#define S5H1432_TUNERLOCKING 0
598c2ecf20Sopenharmony_ci#define S5H1432_DEMODLOCKING 1
608c2ecf20Sopenharmony_ci	u8 status_mode;
618c2ecf20Sopenharmony_ci};
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#if IS_REACHABLE(CONFIG_DVB_S5H1432)
648c2ecf20Sopenharmony_ciextern struct dvb_frontend *s5h1432_attach(const struct s5h1432_config *config,
658c2ecf20Sopenharmony_ci					   struct i2c_adapter *i2c);
668c2ecf20Sopenharmony_ci#else
678c2ecf20Sopenharmony_cistatic inline struct dvb_frontend *s5h1432_attach(const struct s5h1432_config
688c2ecf20Sopenharmony_ci						  *config,
698c2ecf20Sopenharmony_ci						  struct i2c_adapter *i2c)
708c2ecf20Sopenharmony_ci{
718c2ecf20Sopenharmony_ci	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
728c2ecf20Sopenharmony_ci	return NULL;
738c2ecf20Sopenharmony_ci}
748c2ecf20Sopenharmony_ci#endif /* CONFIG_DVB_s5h1432 */
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#endif /* __s5h1432_H__ */
77