^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef __RADIO_TEA5777_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define __RADIO_TEA5777_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * v4l2 driver for TEA5777 Philips AM/FM radio tuner chips
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Based on the ALSA driver for TEA5757/5759 Philips AM/FM radio tuner chips:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Copyright (c) 2004 Jaroslav Kysela <perex@perex.cz>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/videodev2.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <media/v4l2-ctrls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <media/v4l2-dev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <media/v4l2-device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define TEA575X_FMIF 10700
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define TEA575X_AMIF 450
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct radio_tea5777;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct radio_tea5777_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * Write the 6 bytes large write register of the tea5777
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * val represents the 6 write registers, with byte 1 from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * datasheet being the most significant byte (so byte 5 of the u64),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * and byte 6 from the datasheet being the least significant byte.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * returns 0 on success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) int (*write_reg)(struct radio_tea5777 *tea, u64 val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * Read the 3 bytes large read register of the tea5777
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * The read value gets returned in val, akin to write_reg, byte 1 from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * the datasheet is stored as the most significant byte (so byte 2 of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * the u32), and byte 3 from the datasheet gets stored as the least
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * significant byte (iow byte 0 of the u32).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * returns 0 on success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) int (*read_reg)(struct radio_tea5777 *tea, u32 *val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct radio_tea5777 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct v4l2_device *v4l2_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct v4l2_file_operations fops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) struct video_device vd; /* video device */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) bool has_am; /* Device can tune to AM freqs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) bool write_before_read; /* must write before read quirk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) bool needs_write; /* for write before read quirk */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u32 band; /* current band */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u32 freq; /* current frequency */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) u32 audmode; /* last set audmode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) u32 seek_rangelow; /* current hwseek limits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) u32 seek_rangehigh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) u32 read_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) u64 write_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) struct mutex mutex;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) const struct radio_tea5777_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) void *private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) u8 card[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) u8 bus_info[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct v4l2_ctrl_handler ctrl_handler;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) void radio_tea5777_exit(struct radio_tea5777 *tea);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int radio_tea5777_set_freq(struct radio_tea5777 *tea);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #endif /* __RADIO_TEA5777_H */