162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci#ifndef __RADIO_TEA5777_H
362306a36Sopenharmony_ci#define __RADIO_TEA5777_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci/*
662306a36Sopenharmony_ci *   v4l2 driver for TEA5777 Philips AM/FM radio tuner chips
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci *	Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci *   Based on the ALSA driver for TEA5757/5759 Philips AM/FM radio tuner chips:
1162306a36Sopenharmony_ci *
1262306a36Sopenharmony_ci *	Copyright (c) 2004 Jaroslav Kysela <perex@perex.cz>
1362306a36Sopenharmony_ci *	Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
1462306a36Sopenharmony_ci */
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include <linux/videodev2.h>
1762306a36Sopenharmony_ci#include <media/v4l2-ctrls.h>
1862306a36Sopenharmony_ci#include <media/v4l2-dev.h>
1962306a36Sopenharmony_ci#include <media/v4l2-device.h>
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define TEA575X_FMIF	10700
2262306a36Sopenharmony_ci#define TEA575X_AMIF	  450
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_cistruct radio_tea5777;
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_cistruct radio_tea5777_ops {
2762306a36Sopenharmony_ci	/*
2862306a36Sopenharmony_ci	 * Write the 6 bytes large write register of the tea5777
2962306a36Sopenharmony_ci	 *
3062306a36Sopenharmony_ci	 * val represents the 6 write registers, with byte 1 from the
3162306a36Sopenharmony_ci	 * datasheet being the most significant byte (so byte 5 of the u64),
3262306a36Sopenharmony_ci	 * and byte 6 from the datasheet being the least significant byte.
3362306a36Sopenharmony_ci	 *
3462306a36Sopenharmony_ci	 * returns 0 on success.
3562306a36Sopenharmony_ci	 */
3662306a36Sopenharmony_ci	int (*write_reg)(struct radio_tea5777 *tea, u64 val);
3762306a36Sopenharmony_ci	/*
3862306a36Sopenharmony_ci	 * Read the 3 bytes large read register of the tea5777
3962306a36Sopenharmony_ci	 *
4062306a36Sopenharmony_ci	 * The read value gets returned in val, akin to write_reg, byte 1 from
4162306a36Sopenharmony_ci	 * the datasheet is stored as the most significant byte (so byte 2 of
4262306a36Sopenharmony_ci	 * the u32), and byte 3 from the datasheet gets stored as the least
4362306a36Sopenharmony_ci	 * significant byte (iow byte 0 of the u32).
4462306a36Sopenharmony_ci	 *
4562306a36Sopenharmony_ci	 * returns 0 on success.
4662306a36Sopenharmony_ci	 */
4762306a36Sopenharmony_ci	int (*read_reg)(struct radio_tea5777 *tea, u32 *val);
4862306a36Sopenharmony_ci};
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_cistruct radio_tea5777 {
5162306a36Sopenharmony_ci	struct v4l2_device *v4l2_dev;
5262306a36Sopenharmony_ci	struct v4l2_file_operations fops;
5362306a36Sopenharmony_ci	struct video_device vd;		/* video device */
5462306a36Sopenharmony_ci	bool has_am;			/* Device can tune to AM freqs */
5562306a36Sopenharmony_ci	bool write_before_read;		/* must write before read quirk */
5662306a36Sopenharmony_ci	bool needs_write;		/* for write before read quirk */
5762306a36Sopenharmony_ci	u32 band;			/* current band */
5862306a36Sopenharmony_ci	u32 freq;			/* current frequency */
5962306a36Sopenharmony_ci	u32 audmode;			/* last set audmode */
6062306a36Sopenharmony_ci	u32 seek_rangelow;		/* current hwseek limits */
6162306a36Sopenharmony_ci	u32 seek_rangehigh;
6262306a36Sopenharmony_ci	u32 read_reg;
6362306a36Sopenharmony_ci	u64 write_reg;
6462306a36Sopenharmony_ci	struct mutex mutex;
6562306a36Sopenharmony_ci	const struct radio_tea5777_ops *ops;
6662306a36Sopenharmony_ci	void *private_data;
6762306a36Sopenharmony_ci	u8 card[32];
6862306a36Sopenharmony_ci	u8 bus_info[32];
6962306a36Sopenharmony_ci	struct v4l2_ctrl_handler ctrl_handler;
7062306a36Sopenharmony_ci};
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ciint radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner);
7362306a36Sopenharmony_civoid radio_tea5777_exit(struct radio_tea5777 *tea);
7462306a36Sopenharmony_ciint radio_tea5777_set_freq(struct radio_tea5777 *tea);
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci#endif /* __RADIO_TEA5777_H */
77