18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci#ifndef __RADIO_TEA5777_H
38c2ecf20Sopenharmony_ci#define __RADIO_TEA5777_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci/*
68c2ecf20Sopenharmony_ci *   v4l2 driver for TEA5777 Philips AM/FM radio tuner chips
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci *	Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci *   Based on the ALSA driver for TEA5757/5759 Philips AM/FM radio tuner chips:
118c2ecf20Sopenharmony_ci *
128c2ecf20Sopenharmony_ci *	Copyright (c) 2004 Jaroslav Kysela <perex@perex.cz>
138c2ecf20Sopenharmony_ci *	Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
148c2ecf20Sopenharmony_ci */
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#include <linux/videodev2.h>
178c2ecf20Sopenharmony_ci#include <media/v4l2-ctrls.h>
188c2ecf20Sopenharmony_ci#include <media/v4l2-dev.h>
198c2ecf20Sopenharmony_ci#include <media/v4l2-device.h>
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define TEA575X_FMIF	10700
228c2ecf20Sopenharmony_ci#define TEA575X_AMIF	  450
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_cistruct radio_tea5777;
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cistruct radio_tea5777_ops {
278c2ecf20Sopenharmony_ci	/*
288c2ecf20Sopenharmony_ci	 * Write the 6 bytes large write register of the tea5777
298c2ecf20Sopenharmony_ci	 *
308c2ecf20Sopenharmony_ci	 * val represents the 6 write registers, with byte 1 from the
318c2ecf20Sopenharmony_ci	 * datasheet being the most significant byte (so byte 5 of the u64),
328c2ecf20Sopenharmony_ci	 * and byte 6 from the datasheet being the least significant byte.
338c2ecf20Sopenharmony_ci	 *
348c2ecf20Sopenharmony_ci	 * returns 0 on success.
358c2ecf20Sopenharmony_ci	 */
368c2ecf20Sopenharmony_ci	int (*write_reg)(struct radio_tea5777 *tea, u64 val);
378c2ecf20Sopenharmony_ci	/*
388c2ecf20Sopenharmony_ci	 * Read the 3 bytes large read register of the tea5777
398c2ecf20Sopenharmony_ci	 *
408c2ecf20Sopenharmony_ci	 * The read value gets returned in val, akin to write_reg, byte 1 from
418c2ecf20Sopenharmony_ci	 * the datasheet is stored as the most significant byte (so byte 2 of
428c2ecf20Sopenharmony_ci	 * the u32), and byte 3 from the datasheet gets stored as the least
438c2ecf20Sopenharmony_ci	 * significant byte (iow byte 0 of the u32).
448c2ecf20Sopenharmony_ci	 *
458c2ecf20Sopenharmony_ci	 * returns 0 on success.
468c2ecf20Sopenharmony_ci	 */
478c2ecf20Sopenharmony_ci	int (*read_reg)(struct radio_tea5777 *tea, u32 *val);
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_cistruct radio_tea5777 {
518c2ecf20Sopenharmony_ci	struct v4l2_device *v4l2_dev;
528c2ecf20Sopenharmony_ci	struct v4l2_file_operations fops;
538c2ecf20Sopenharmony_ci	struct video_device vd;		/* video device */
548c2ecf20Sopenharmony_ci	bool has_am;			/* Device can tune to AM freqs */
558c2ecf20Sopenharmony_ci	bool write_before_read;		/* must write before read quirk */
568c2ecf20Sopenharmony_ci	bool needs_write;		/* for write before read quirk */
578c2ecf20Sopenharmony_ci	u32 band;			/* current band */
588c2ecf20Sopenharmony_ci	u32 freq;			/* current frequency */
598c2ecf20Sopenharmony_ci	u32 audmode;			/* last set audmode */
608c2ecf20Sopenharmony_ci	u32 seek_rangelow;		/* current hwseek limits */
618c2ecf20Sopenharmony_ci	u32 seek_rangehigh;
628c2ecf20Sopenharmony_ci	u32 read_reg;
638c2ecf20Sopenharmony_ci	u64 write_reg;
648c2ecf20Sopenharmony_ci	struct mutex mutex;
658c2ecf20Sopenharmony_ci	const struct radio_tea5777_ops *ops;
668c2ecf20Sopenharmony_ci	void *private_data;
678c2ecf20Sopenharmony_ci	u8 card[32];
688c2ecf20Sopenharmony_ci	u8 bus_info[32];
698c2ecf20Sopenharmony_ci	struct v4l2_ctrl_handler ctrl_handler;
708c2ecf20Sopenharmony_ci};
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ciint radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner);
738c2ecf20Sopenharmony_civoid radio_tea5777_exit(struct radio_tea5777 *tea);
748c2ecf20Sopenharmony_ciint radio_tea5777_set_freq(struct radio_tea5777 *tea);
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#endif /* __RADIO_TEA5777_H */
77