satip-client: update patch for lock-handling
[opendreambox.git] / meta-opendreambox / recipes-dreambox / satip-client / satip-client / 0002-enable-proper-lock-handling.patch
1 From 1234b4e8ec91af2be401e226ed5c228ff1f9058a Mon Sep 17 00:00:00 2001
2 From: Stephan Reichholf <reichi@opendreambox.org>
3 Date: Thu, 9 Feb 2017 21:53:52 +0100
4 Subject: [PATCH 2/2] enable proper lock handling
5
6 ---
7  rtp.cpp    | 13 +++++++++----
8  rtp.h      |  1 +
9  vtuner.cpp | 22 ++++++++++++++--------
10  vtuner.h   | 12 +++++++++++-
11  4 files changed, 35 insertions(+), 13 deletions(-)
12
13 diff --git a/rtp.cpp b/rtp.cpp
14 index 95cd3d4..c4d00c0 100644
15 --- a/rtp.cpp
16 +++ b/rtp.cpp
17 @@ -43,7 +43,7 @@ satipRTP::satipRTP(int vtuner_fd)
18                                                 m_rtcp_socket(-1),
19                                                 m_thread(0),
20                                                 m_running(false),
21 -                                               m_hasLock(true),
22 +                                               m_hasLock(false),
23                                                 m_signalStrength(0),
24                                                 m_signalQuality(0),
25                                                 m_openok(false)
26 @@ -67,6 +67,13 @@ satipRTP::~satipRTP()
27                 close(m_rtp_socket);
28  }
29  
30 +void satipRTP::unset()
31 +{
32 +       m_signalStrength = 0;
33 +       m_hasLock = false;
34 +       m_signalQuality = 0;
35 +}
36 +
37  int satipRTP::openRTP()
38  {
39         int rtp_sock;
40 @@ -154,9 +161,7 @@ void satipRTP::parseRtcpAppPayload(char *buffer)
41                 quality (Signal quality) : Numerical value between 0 and 15
42         */
43  
44 -       m_signalStrength = 0;
45 -       m_hasLock = false;
46 -       m_signalQuality = 0;
47 +       unset();
48  
49         char *strp = strstr(buffer, ";tuner=");
50         if (strp)
51 diff --git a/rtp.h b/rtp.h
52 index 7114bc4..8995b38 100644
53 --- a/rtp.h
54 +++ b/rtp.h
55 @@ -48,6 +48,7 @@ class satipRTP
56  public:
57         satipRTP(int vtuner_fd);
58         virtual ~satipRTP();
59 +       void unset();
60         int get_rtp_port() { return m_rtp_port; }
61         int get_rtp_socket() { return m_rtp_socket; }
62         int get_rtcp_port() { return m_rtcp_port; }
63 diff --git a/vtuner.cpp b/vtuner.cpp
64 index 5291cb6..b1fcb52 100644
65 --- a/vtuner.cpp
66 +++ b/vtuner.cpp
67 @@ -497,14 +497,10 @@ void satipVtuner::vtunerEvent()
68  
69                 case MSG_READ_STATUS:
70                         //INFO(MSG_MAIN,"MSG_READ_STATUS\n");
71 -//                             if (m_satip_rtp)
72 -//                             {
73 -//                                     if (m_satip_rtp->getHasLock())
74 -//                                             msg.body.status = FE_HAS_LOCK;
75 -//                                     else
76 -//                                             msg.body.status = 0;
77 -//                             }
78 -                       msg.body.status = FE_HAS_LOCK;
79 +                       if (m_satip_rtp && m_satip_rtp->getHasLock())
80 +                               msg.body.status = FE_HAS_LOCK;
81 +                       else
82 +                               msg.body.status = 0;
83                         break;
84                 case MSG_READ_BER:
85                         //INFO(MSG_MAIN,"MSG_READ_BER\n");
86 @@ -559,6 +555,16 @@ void satipVtuner::vtunerEvent()
87                         DEBUG(MSG_MAIN,"MSG_GET_PROPERTY\n");
88                         break;
89  
90 +               case MSG_GET_TUNE_SETTINGS:
91 +                       DEBUG(MSG_MAIN,"MSG_GET_TUNE_SETTINGS\n");
92 +                       if (m_satip_rtp) {
93 +                               m_satip_rtp->unset();
94 +                       }
95 +                       msg.body.tune_settings.min_delay_ms = 50; // let linux-tv api ask every 50ms for locked/unlocked state...
96 +                       msg.body.tune_settings.step_size = 0;
97 +                       msg.body.tune_settings.max_drift = 0;
98 +                       break;
99 +
100                 default:
101                         DEBUG(MSG_MAIN,"MSG_UNKNOWN: %d\n", msg.type);
102                         break;
103 diff --git a/vtuner.h b/vtuner.h
104 index 33db6c5..990dec4 100644
105 --- a/vtuner.h
106 +++ b/vtuner.h
107 @@ -45,6 +45,7 @@
108  #define MSG_TYPE_CHANGED                       15
109  #define MSG_SET_PROPERTY                       16
110  #define MSG_GET_PROPERTY                       17
111 +#define MSG_GET_TUNE_SETTINGS          18
112  
113  #define MSG_NULL                               1024
114  #define MSG_DISCOVER                   1025
115 @@ -54,12 +55,20 @@ typedef unsigned int   u32;
116  typedef unsigned short u16;
117  typedef unsigned char  u8;
118  
119 +struct dvb_frontend_tune_settings
120 +{
121 +       int min_delay_ms;
122 +       int step_size;
123 +       int max_drift;
124 +};
125 +
126  #if VMSG_TYPE1
127  struct vtuner_message {
128         __u32 type;
129         union 
130         {
131 -        struct dvb_frontend_parameters fe_params;
132 +               struct dvb_frontend_parameters fe_params;
133 +               struct dvb_frontend_tune_settings tune_settings;
134  
135  #if DVB_API_VERSION >= 5
136                 struct dtv_property prop;
137 @@ -117,6 +126,7 @@ struct vtuner_message
138                  } vsb;
139              } u;
140          } fe_params;
141 +               struct dvb_frontend_tune_settings tune_settings;
142          struct dtv_property prop;
143          u32 status;
144          __u32 ber;
145 -- 
146 2.7.4
147