Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 #ifndef __RADIO_TEA5777_H
0003 #define __RADIO_TEA5777_H
0004 
0005 /*
0006  *   v4l2 driver for TEA5777 Philips AM/FM radio tuner chips
0007  *
0008  *  Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
0009  *
0010  *   Based on the ALSA driver for TEA5757/5759 Philips AM/FM radio tuner chips:
0011  *
0012  *  Copyright (c) 2004 Jaroslav Kysela <perex@perex.cz>
0013  *  Copyright (c) 2012 Hans de Goede <hdegoede@redhat.com>
0014  */
0015 
0016 #include <linux/videodev2.h>
0017 #include <media/v4l2-ctrls.h>
0018 #include <media/v4l2-dev.h>
0019 #include <media/v4l2-device.h>
0020 
0021 #define TEA575X_FMIF    10700
0022 #define TEA575X_AMIF      450
0023 
0024 struct radio_tea5777;
0025 
0026 struct radio_tea5777_ops {
0027     /*
0028      * Write the 6 bytes large write register of the tea5777
0029      *
0030      * val represents the 6 write registers, with byte 1 from the
0031      * datasheet being the most significant byte (so byte 5 of the u64),
0032      * and byte 6 from the datasheet being the least significant byte.
0033      *
0034      * returns 0 on success.
0035      */
0036     int (*write_reg)(struct radio_tea5777 *tea, u64 val);
0037     /*
0038      * Read the 3 bytes large read register of the tea5777
0039      *
0040      * The read value gets returned in val, akin to write_reg, byte 1 from
0041      * the datasheet is stored as the most significant byte (so byte 2 of
0042      * the u32), and byte 3 from the datasheet gets stored as the least
0043      * significant byte (iow byte 0 of the u32).
0044      *
0045      * returns 0 on success.
0046      */
0047     int (*read_reg)(struct radio_tea5777 *tea, u32 *val);
0048 };
0049 
0050 struct radio_tea5777 {
0051     struct v4l2_device *v4l2_dev;
0052     struct v4l2_file_operations fops;
0053     struct video_device vd;     /* video device */
0054     bool has_am;            /* Device can tune to AM freqs */
0055     bool write_before_read;     /* must write before read quirk */
0056     bool needs_write;       /* for write before read quirk */
0057     u32 band;           /* current band */
0058     u32 freq;           /* current frequency */
0059     u32 audmode;            /* last set audmode */
0060     u32 seek_rangelow;      /* current hwseek limits */
0061     u32 seek_rangehigh;
0062     u32 read_reg;
0063     u64 write_reg;
0064     struct mutex mutex;
0065     const struct radio_tea5777_ops *ops;
0066     void *private_data;
0067     u8 card[32];
0068     u8 bus_info[32];
0069     struct v4l2_ctrl_handler ctrl_handler;
0070 };
0071 
0072 int radio_tea5777_init(struct radio_tea5777 *tea, struct module *owner);
0073 void radio_tea5777_exit(struct radio_tea5777 *tea);
0074 int radio_tea5777_set_freq(struct radio_tea5777 *tea);
0075 
0076 #endif /* __RADIO_TEA5777_H */