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  */
25 
26 #include <linux/videodev2.h>
27 #include <media/v4l2-ctrls.h>
28 #include <media/v4l2-dev.h>
29 #include <media/v4l2-device.h>
30 
31 #define TEA575X_FMIF	10700
32 #define TEA575X_AMIF	  450
33 
34 struct radio_tea5777;
35 
36 struct radio_tea5777_ops {
37 	/*
38 	 * Write the 6 bytes large write register of the tea5777
39 	 *
40 	 * val represents the 6 write registers, with byte 1 from the
41 	 * datasheet being the most significant byte (so byte 5 of the u64),
42 	 * and byte 6 from the datasheet being the least significant byte.
43 	 *
44 	 * returns 0 on success.
45 	 */
46 	int (*write_reg)(struct radio_tea5777 *tea, u64 val);
47 	/*
48 	 * Read the 3 bytes large read register of the tea5777
49 	 *
50 	 * The read value gets returned in val, akin to write_reg, byte 1 from
51 	 * the datasheet is stored as the most significant byte (so byte 2 of
52 	 * the u32), and byte 3 from the datasheet gets stored as the least
53 	 * significant byte (iow byte 0 of the u32).
54 	 *
55 	 * returns 0 on success.
56 	 */
57 	int (*read_reg)(struct radio_tea5777 *tea, u32 *val);
58 };
59 
60 struct radio_tea5777 {
61 	struct v4l2_device *v4l2_dev;
62 	struct v4l2_file_operations fops;
63 	struct video_device vd;		/* video device */
64 	bool has_am;			/* Device can tune to AM freqs */
65 	bool write_before_read;		/* must write before read quirk */
66 	bool needs_write;		/* for write before read quirk */
67 	u32 band;			/* current band */
68 	u32 freq;			/* current frequency */
69 	u32 audmode;			/* last set audmode */
70 	u32 seek_rangelow;		/* current hwseek limits */
71 	u32 seek_rangehigh;
72 	u32 read_reg;
73 	u64 write_reg;
74 	struct mutex mutex;
75 	const struct radio_tea5777_ops *ops;
76 	void *private_data;
77 	u8 card[32];
78 	u8 bus_info[32];
79 	struct v4l2_ctrl_handler ctrl_handler;
80 };
81 
82 int radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner);
83 void radio_tea5777_exit(struct radio_tea5777 *tea);
84 int radio_tea5777_set_freq(struct radio_tea5777 *tea);
85 
86 #endif /* __RADIO_TEA5777_H */
87