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