gqradio-1.9.2-v4l2.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. diff -Naur gqradio-1.9.2/src/io_radio.c gqradio-1.9.2-new/src/io_radio.c
  2. --- gqradio-1.9.2/src/io_radio.c 2005-02-23 01:01:18.000000000 -0300
  3. +++ gqradio-1.9.2-new/src/io_radio.c 2012-10-25 19:54:14.038303871 -0200
  4. @@ -37,7 +37,7 @@
  5. #if defined(linux) && defined(HAVE_VIDEO4LINUX)
  6. #include <fcntl.h>
  7. #include <sys/ioctl.h>
  8. - #include <linux/videodev.h>
  9. + #include <linux/videodev2.h>
  10. #include <errno.h>
  11. #elif defined(HAVE_IOCTL_BT848)
  12. #include <fcntl.h>
  13. @@ -108,9 +108,9 @@
  14. printf("Error talking (ioctl) to %s, %s\n", RADIO_DEVICE, strerror(errno));
  15. }
  16. -static guint radio_calc_steps(struct video_tuner *t)
  17. +static guint radio_calc_steps(struct v4l2_tuner *t)
  18. {
  19. - if ( (t->flags & VIDEO_TUNER_LOW) )
  20. + if ( (t->capability & V4L2_TUNER_CAP_LOW) )
  21. {
  22. return 16000; /* field is KHz */
  23. }
  24. @@ -149,27 +149,21 @@
  25. static gint radio_control_set_mute(gint mute)
  26. {
  27. - struct video_audio av;
  28. + struct v4l2_control control;
  29. if (v4l_fd == -1) return FALSE;
  30. - if (ioctl(v4l_fd, VIDIOCGAUDIO, &av) != 0)
  31. - {
  32. - radio_error_message();
  33. - return FALSE;
  34. - }
  35. -
  36. + control.id = V4L2_CID_AUDIO_MUTE;
  37. if (mute)
  38. {
  39. - av.flags |= VIDEO_AUDIO_MUTE;
  40. + control.value = 1;
  41. }
  42. else
  43. {
  44. - if (av.volume == 0 || radio_volume_boost) av.volume = 65535;
  45. - av.flags &= ~VIDEO_AUDIO_MUTE;
  46. + control.value = 0;
  47. }
  48. - if (ioctl(v4l_fd, VIDIOCSAUDIO, &av) != 0)
  49. + if (ioctl(v4l_fd, VIDIOC_S_CTRL, &control) != 0)
  50. {
  51. radio_error_message();
  52. return FALSE;
  53. @@ -180,15 +174,15 @@
  54. static gint radio_control_set_freq(guint32 freq)
  55. {
  56. - struct video_tuner t;
  57. + struct v4l2_tuner t;
  58. + struct v4l2_frequency vfreq;
  59. guint32 f;
  60. guint m;
  61. if (v4l_fd == -1) return FALSE;
  62. - t.tuner = 0;
  63. -
  64. - if (ioctl(v4l_fd, VIDIOCGTUNER, &t) == 0)
  65. + memset(&t, 0, sizeof(struct v4l2_tuner));
  66. + if (ioctl(v4l_fd, VIDIOC_G_TUNER, &t) == 0)
  67. {
  68. m = radio_calc_steps(&t);
  69. }
  70. @@ -199,7 +193,10 @@
  71. }
  72. f = (guint32)((gfloat)freq / 1000000.0 * m);
  73. - if (ioctl(v4l_fd, VIDIOCSFREQ, &f) != 0)
  74. + vfreq.tuner = 0;
  75. + vfreq.type = V4L2_TUNER_RADIO;
  76. + vfreq.frequency = f;
  77. + if (ioctl(v4l_fd, VIDIOC_S_FREQUENCY, &vfreq) != 0)
  78. {
  79. radio_error_message();
  80. return FALSE;
  81. @@ -239,7 +236,7 @@
  82. static gint radio_real_test(void)
  83. {
  84. - struct video_tuner t;
  85. + struct v4l2_tuner t;
  86. if (!radio_device) radio_device = g_strdup(RADIO_DEVICE);
  87. @@ -256,9 +253,8 @@
  88. return FALSE;
  89. }
  90. - t.tuner = 0;
  91. -
  92. - if (ioctl(v4l_fd, VIDIOCGTUNER, &t) == 0)
  93. + memset(&t, 0, sizeof(struct v4l2_tuner));
  94. + if (ioctl(v4l_fd, VIDIOC_G_TUNER, &t) == 0)
  95. {
  96. guint g;
  97. @@ -281,19 +277,19 @@
  98. /* stereo is 0 or 1, strength is 0 to 100 (%) */
  99. static gint radio_real_status(gint *stereo, gint *strength)
  100. {
  101. - struct video_tuner t;
  102. - struct video_audio av;
  103. + struct v4l2_tuner t;
  104. if (v4l_fd == -1 || !stereo || !strength) return FALSE;
  105. /* stereo */
  106. - if (ioctl(v4l_fd, VIDIOCGAUDIO, &av) != 0)
  107. + memset(&t, 0, sizeof(struct v4l2_tuner));
  108. + if (ioctl(v4l_fd, VIDIOC_G_TUNER, &t) != 0)
  109. {
  110. radio_error_message();
  111. return FALSE;
  112. }
  113. - if ( (av.mode & VIDEO_SOUND_STEREO) )
  114. + if ( (t.audmode & V4L2_TUNER_MODE_STEREO) )
  115. {
  116. *stereo = TRUE;
  117. }
  118. @@ -304,12 +300,6 @@
  119. /* strength */
  120. - t.tuner = 0;
  121. - if (ioctl(v4l_fd, VIDIOCGTUNER, &t) != 0)
  122. - {
  123. - radio_error_message();
  124. - return FALSE;
  125. - }
  126. *strength = (double)t.signal / 65535.0 * 100.0; /* 16bit scale */
  127. return TRUE;