radio-tea5777.h 2.7 KB

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