radio-tea5777.h 2.9 KB

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