18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci    Samsung S5H1411 VSB/QAM demodulator driver
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci    Copyright (C) 2008 Steven Toth <stoth@linuxtv.org>
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci*/
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef __S5H1411_H__
118c2ecf20Sopenharmony_ci#define __S5H1411_H__
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <linux/dvb/frontend.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#define S5H1411_I2C_TOP_ADDR (0x32 >> 1)
168c2ecf20Sopenharmony_ci#define S5H1411_I2C_QAM_ADDR (0x34 >> 1)
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_cistruct s5h1411_config {
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci	/* serial/parallel output */
218c2ecf20Sopenharmony_ci#define S5H1411_PARALLEL_OUTPUT 0
228c2ecf20Sopenharmony_ci#define S5H1411_SERIAL_OUTPUT   1
238c2ecf20Sopenharmony_ci	u8 output_mode;
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci	/* GPIO Setting */
268c2ecf20Sopenharmony_ci#define S5H1411_GPIO_OFF 0
278c2ecf20Sopenharmony_ci#define S5H1411_GPIO_ON  1
288c2ecf20Sopenharmony_ci	u8 gpio;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci	/* MPEG signal timing */
318c2ecf20Sopenharmony_ci#define S5H1411_MPEGTIMING_CONTINUOUS_INVERTING_CLOCK       0
328c2ecf20Sopenharmony_ci#define S5H1411_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK    1
338c2ecf20Sopenharmony_ci#define S5H1411_MPEGTIMING_NONCONTINUOUS_INVERTING_CLOCK    2
348c2ecf20Sopenharmony_ci#define S5H1411_MPEGTIMING_NONCONTINUOUS_NONINVERTING_CLOCK 3
358c2ecf20Sopenharmony_ci	u16 mpeg_timing;
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ci	/* IF Freq for QAM and VSB in KHz */
388c2ecf20Sopenharmony_ci#define S5H1411_IF_3250  3250
398c2ecf20Sopenharmony_ci#define S5H1411_IF_3500  3500
408c2ecf20Sopenharmony_ci#define S5H1411_IF_4000  4000
418c2ecf20Sopenharmony_ci#define S5H1411_IF_5380  5380
428c2ecf20Sopenharmony_ci#define S5H1411_IF_44000 44000
438c2ecf20Sopenharmony_ci#define S5H1411_VSB_IF_DEFAULT S5H1411_IF_44000
448c2ecf20Sopenharmony_ci#define S5H1411_QAM_IF_DEFAULT S5H1411_IF_44000
458c2ecf20Sopenharmony_ci	u16 qam_if;
468c2ecf20Sopenharmony_ci	u16 vsb_if;
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ci	/* Spectral Inversion */
498c2ecf20Sopenharmony_ci#define S5H1411_INVERSION_OFF 0
508c2ecf20Sopenharmony_ci#define S5H1411_INVERSION_ON  1
518c2ecf20Sopenharmony_ci	u8 inversion;
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci	/* Return lock status based on tuner lock, or demod lock */
548c2ecf20Sopenharmony_ci#define S5H1411_TUNERLOCKING 0
558c2ecf20Sopenharmony_ci#define S5H1411_DEMODLOCKING 1
568c2ecf20Sopenharmony_ci	u8 status_mode;
578c2ecf20Sopenharmony_ci};
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#if IS_REACHABLE(CONFIG_DVB_S5H1411)
608c2ecf20Sopenharmony_ciextern struct dvb_frontend *s5h1411_attach(const struct s5h1411_config *config,
618c2ecf20Sopenharmony_ci					   struct i2c_adapter *i2c);
628c2ecf20Sopenharmony_ci#else
638c2ecf20Sopenharmony_cistatic inline struct dvb_frontend *s5h1411_attach(
648c2ecf20Sopenharmony_ci	const struct s5h1411_config *config,
658c2ecf20Sopenharmony_ci	struct i2c_adapter *i2c)
668c2ecf20Sopenharmony_ci{
678c2ecf20Sopenharmony_ci	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
688c2ecf20Sopenharmony_ci	return NULL;
698c2ecf20Sopenharmony_ci}
708c2ecf20Sopenharmony_ci#endif /* CONFIG_DVB_S5H1411 */
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci#endif /* __S5H1411_H__ */
73