1 #ifndef __RADIO_TEA5777_H
2 #define __RADIO_TEA5777_H
3 
4 /*
5  *   v4l2 driver for TEA5777 Philips AM/FM radio tuner chips
6  *
7  *	Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
8  *
9  *   Based on the ALSA driver for TEA5757/5759 Philips AM/FM radio tuner chips:
10  *
11  *	Copyright (c) 2004 Jaroslav Kysela <perex@perex.cz>
12  *	Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
13  *
14  *   This program is free software; you can redistribute it and/or modify
15  *   it under the terms of the GNU General Public License as published by
16  *   the Free Software Foundation; either version 2 of the License, or
17  *   (at your option) any later version.
18  *
19  *   This program is distributed in the hope that it will be useful,
20  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
21  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  *   GNU General Public License for more details.
23  *
24  *   You should have received a copy of the GNU General Public License
25  *   along with this program; if not, write to the Free Software
26  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
27  *
28  */
29 
30 #include <linux/videodev2.h>
31 #include <media/v4l2-ctrls.h>
32 #include <media/v4l2-dev.h>
33 #include <media/v4l2-device.h>
34 
35 #define TEA575X_FMIF	10700
36 #define TEA575X_AMIF	  450
37 
38 struct radio_tea5777;
39 
40 struct radio_tea5777_ops {
41 	/*
42 	 * Write the 6 bytes large write register of the tea5777
43 	 *
44 	 * val represents the 6 write registers, with byte 1 from the
45 	 * datasheet being the most significant byte (so byte 5 of the u64),
46 	 * and byte 6 from the datasheet being the least significant byte.
47 	 *
48 	 * returns 0 on success.
49 	 */
50 	int (*write_reg)(struct radio_tea5777 *tea, u64 val);
51 	/*
52 	 * Read the 3 bytes large read register of the tea5777
53 	 *
54 	 * The read value gets returned in val, akin to write_reg, byte 1 from
55 	 * the datasheet is stored as the most significant byte (so byte 2 of
56 	 * the u32), and byte 3 from the datasheet gets stored as the least
57 	 * significant byte (iow byte 0 of the u32).
58 	 *
59 	 * returns 0 on success.
60 	 */
61 	int (*read_reg)(struct radio_tea5777 *tea, u32 *val);
62 };
63 
64 struct radio_tea5777 {
65 	struct v4l2_device *v4l2_dev;
66 	struct v4l2_file_operations fops;
67 	struct video_device vd;		/* video device */
68 	bool has_am;			/* Device can tune to AM freqs */
69 	bool write_before_read;		/* must write before read quirk */
70 	bool needs_write;		/* for write before read quirk */
71 	u32 band;			/* current band */
72 	u32 freq;			/* current frequency */
73 	u32 audmode;			/* last set audmode */
74 	u32 seek_rangelow;		/* current hwseek limits */
75 	u32 seek_rangehigh;
76 	u32 read_reg;
77 	u64 write_reg;
78 	struct mutex mutex;
79 	struct radio_tea5777_ops *ops;
80 	void *private_data;
81 	u8 card[32];
82 	u8 bus_info[32];
83 	struct v4l2_ctrl_handler ctrl_handler;
84 };
85 
86 int radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner);
87 void radio_tea5777_exit(struct radio_tea5777 *tea);
88 int radio_tea5777_set_freq(struct radio_tea5777 *tea);
89 
90 #endif /* __RADIO_TEA5777_H */
91