diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-12-22 12:47:48 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-12-31 06:10:49 -0500 |
commit | a689e3657d7e82c2271008553c709fc79fb2e038 (patch) | |
tree | 88c1edf1deacd41733ce5b31566c6fd187a52e11 /drivers/media/dvb/dvb-core | |
parent | bc9cd2736b34619b58961d506210fe0e6dfaa27d (diff) |
[media] dvb-core: add support for a DVBv5 get_frontend() callback
Creates a DVBv5 get_frontend call, renaming the DVBv3 one to
get_frontend_legacy(), while not all frontends are converted.
After the conversion for all drivers, get_frontend_legacy()
will be removed.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-core')
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_frontend.c | 102 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_frontend.h | 5 |
2 files changed, 82 insertions, 25 deletions
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c index 930868fc1130..7246c914a70c 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb/dvb-core/dvb_frontend.c | |||
@@ -139,6 +139,14 @@ struct dvb_frontend_private { | |||
139 | }; | 139 | }; |
140 | 140 | ||
141 | static void dvb_frontend_wakeup(struct dvb_frontend *fe); | 141 | static void dvb_frontend_wakeup(struct dvb_frontend *fe); |
142 | static int dtv_get_frontend(struct dvb_frontend *fe, | ||
143 | struct dtv_frontend_properties *c, | ||
144 | struct dvb_frontend_parameters *p_out); | ||
145 | |||
146 | static bool has_get_frontend(struct dvb_frontend *fe) | ||
147 | { | ||
148 | return fe->ops.get_frontend || fe->ops.get_frontend_legacy; | ||
149 | } | ||
142 | 150 | ||
143 | static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) | 151 | static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) |
144 | { | 152 | { |
@@ -149,8 +157,8 @@ static void dvb_frontend_add_event(struct dvb_frontend *fe, fe_status_t status) | |||
149 | 157 | ||
150 | dprintk ("%s\n", __func__); | 158 | dprintk ("%s\n", __func__); |
151 | 159 | ||
152 | if ((status & FE_HAS_LOCK) && fe->ops.get_frontend) | 160 | if ((status & FE_HAS_LOCK) && has_get_frontend(fe)) |
153 | fe->ops.get_frontend(fe, &fepriv->parameters_out); | 161 | dtv_get_frontend(fe, NULL, &fepriv->parameters_out); |
154 | 162 | ||
155 | mutex_lock(&events->mtx); | 163 | mutex_lock(&events->mtx); |
156 | 164 | ||
@@ -1097,11 +1105,10 @@ static void dtv_property_cache_sync(struct dvb_frontend *fe, | |||
1097 | /* Ensure the cached values are set correctly in the frontend | 1105 | /* Ensure the cached values are set correctly in the frontend |
1098 | * legacy tuning structures, for the advanced tuning API. | 1106 | * legacy tuning structures, for the advanced tuning API. |
1099 | */ | 1107 | */ |
1100 | static void dtv_property_legacy_params_sync(struct dvb_frontend *fe) | 1108 | static void dtv_property_legacy_params_sync(struct dvb_frontend *fe, |
1109 | struct dvb_frontend_parameters *p) | ||
1101 | { | 1110 | { |
1102 | const struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 1111 | const struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
1103 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | ||
1104 | struct dvb_frontend_parameters *p = &fepriv->parameters_in; | ||
1105 | 1112 | ||
1106 | p->frequency = c->frequency; | 1113 | p->frequency = c->frequency; |
1107 | p->inversion = c->inversion; | 1114 | p->inversion = c->inversion; |
@@ -1223,6 +1230,7 @@ static void dtv_property_adv_params_sync(struct dvb_frontend *fe) | |||
1223 | static void dtv_property_cache_submit(struct dvb_frontend *fe) | 1230 | static void dtv_property_cache_submit(struct dvb_frontend *fe) |
1224 | { | 1231 | { |
1225 | const struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 1232 | const struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
1233 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | ||
1226 | 1234 | ||
1227 | /* For legacy delivery systems we don't need the delivery_system to | 1235 | /* For legacy delivery systems we don't need the delivery_system to |
1228 | * be specified, but we populate the older structures from the cache | 1236 | * be specified, but we populate the older structures from the cache |
@@ -1231,7 +1239,7 @@ static void dtv_property_cache_submit(struct dvb_frontend *fe) | |||
1231 | if(is_legacy_delivery_system(c->delivery_system)) { | 1239 | if(is_legacy_delivery_system(c->delivery_system)) { |
1232 | 1240 | ||
1233 | dprintk("%s() legacy, modulation = %d\n", __func__, c->modulation); | 1241 | dprintk("%s() legacy, modulation = %d\n", __func__, c->modulation); |
1234 | dtv_property_legacy_params_sync(fe); | 1242 | dtv_property_legacy_params_sync(fe, &fepriv->parameters_in); |
1235 | 1243 | ||
1236 | } else { | 1244 | } else { |
1237 | dprintk("%s() adv, modulation = %d\n", __func__, c->modulation); | 1245 | dprintk("%s() adv, modulation = %d\n", __func__, c->modulation); |
@@ -1246,6 +1254,58 @@ static void dtv_property_cache_submit(struct dvb_frontend *fe) | |||
1246 | } | 1254 | } |
1247 | } | 1255 | } |
1248 | 1256 | ||
1257 | /** | ||
1258 | * dtv_get_frontend - calls a callback for retrieving DTV parameters | ||
1259 | * @fe: struct dvb_frontend pointer | ||
1260 | * @c: struct dtv_frontend_properties pointer (DVBv5 cache) | ||
1261 | * @p_out struct dvb_frontend_parameters pointer (DVBv3 FE struct) | ||
1262 | * | ||
1263 | * This routine calls either the DVBv3 or DVBv5 get_frontend call. | ||
1264 | * If c is not null, it will update the DVBv5 cache struct pointed by it. | ||
1265 | * If p_out is not null, it will update the DVBv3 params pointed by it. | ||
1266 | */ | ||
1267 | static int dtv_get_frontend(struct dvb_frontend *fe, | ||
1268 | struct dtv_frontend_properties *c, | ||
1269 | struct dvb_frontend_parameters *p_out) | ||
1270 | { | ||
1271 | const struct dtv_frontend_properties *cache = &fe->dtv_property_cache; | ||
1272 | struct dtv_frontend_properties tmp_cache; | ||
1273 | struct dvb_frontend_parameters tmp_out; | ||
1274 | bool fill_cache = (c != NULL); | ||
1275 | bool fill_params = (p_out != NULL); | ||
1276 | int r; | ||
1277 | |||
1278 | if (!p_out) | ||
1279 | p_out = &tmp_out; | ||
1280 | |||
1281 | if (!c) | ||
1282 | c = &tmp_cache; | ||
1283 | else | ||
1284 | memcpy(c, cache, sizeof(*c)); | ||
1285 | |||
1286 | /* Then try the DVBv5 one */ | ||
1287 | if (fe->ops.get_frontend) { | ||
1288 | r = fe->ops.get_frontend(fe, c); | ||
1289 | if (unlikely(r < 0)) | ||
1290 | return r; | ||
1291 | if (fill_params) | ||
1292 | dtv_property_legacy_params_sync(fe, p_out); | ||
1293 | return 0; | ||
1294 | } | ||
1295 | |||
1296 | /* As no DVBv5 call exists, use the DVBv3 one */ | ||
1297 | if (fe->ops.get_frontend_legacy) { | ||
1298 | r = fe->ops.get_frontend_legacy(fe, p_out); | ||
1299 | if (unlikely(r < 0)) | ||
1300 | return r; | ||
1301 | if (fill_cache) | ||
1302 | dtv_property_cache_sync(fe, c, p_out); | ||
1303 | return 0; | ||
1304 | } | ||
1305 | |||
1306 | return -EOPNOTSUPP; | ||
1307 | } | ||
1308 | |||
1249 | static int dvb_frontend_ioctl_legacy(struct file *file, | 1309 | static int dvb_frontend_ioctl_legacy(struct file *file, |
1250 | unsigned int cmd, void *parg); | 1310 | unsigned int cmd, void *parg); |
1251 | static int dvb_frontend_ioctl_properties(struct file *file, | 1311 | static int dvb_frontend_ioctl_properties(struct file *file, |
@@ -1296,24 +1356,12 @@ static void dtv_set_default_delivery_caps(const struct dvb_frontend *fe, struct | |||
1296 | } | 1356 | } |
1297 | 1357 | ||
1298 | static int dtv_property_process_get(struct dvb_frontend *fe, | 1358 | static int dtv_property_process_get(struct dvb_frontend *fe, |
1359 | const struct dtv_frontend_properties *c, | ||
1299 | struct dtv_property *tvp, | 1360 | struct dtv_property *tvp, |
1300 | struct file *file) | 1361 | struct file *file) |
1301 | { | 1362 | { |
1302 | const struct dtv_frontend_properties *c = &fe->dtv_property_cache; | ||
1303 | struct dvb_frontend_private *fepriv = fe->frontend_priv; | ||
1304 | struct dtv_frontend_properties cdetected; | ||
1305 | int r; | 1363 | int r; |
1306 | 1364 | ||
1307 | /* | ||
1308 | * If the driver implements a get_frontend function, then convert | ||
1309 | * detected parameters to S2API properties. | ||
1310 | */ | ||
1311 | if (fe->ops.get_frontend) { | ||
1312 | cdetected = *c; | ||
1313 | dtv_property_cache_sync(fe, &cdetected, &fepriv->parameters_out); | ||
1314 | c = &cdetected; | ||
1315 | } | ||
1316 | |||
1317 | switch(tvp->cmd) { | 1365 | switch(tvp->cmd) { |
1318 | case DTV_ENUM_DELSYS: | 1366 | case DTV_ENUM_DELSYS: |
1319 | dtv_set_default_delivery_caps(fe, tvp); | 1367 | dtv_set_default_delivery_caps(fe, tvp); |
@@ -1685,6 +1733,7 @@ static int dvb_frontend_ioctl_properties(struct file *file, | |||
1685 | 1733 | ||
1686 | } else | 1734 | } else |
1687 | if(cmd == FE_GET_PROPERTY) { | 1735 | if(cmd == FE_GET_PROPERTY) { |
1736 | struct dtv_frontend_properties cache_out; | ||
1688 | 1737 | ||
1689 | tvps = (struct dtv_properties __user *)parg; | 1738 | tvps = (struct dtv_properties __user *)parg; |
1690 | 1739 | ||
@@ -1707,8 +1756,13 @@ static int dvb_frontend_ioctl_properties(struct file *file, | |||
1707 | goto out; | 1756 | goto out; |
1708 | } | 1757 | } |
1709 | 1758 | ||
1759 | /* | ||
1760 | * Fills the cache out struct with the cache contents, plus | ||
1761 | * the data retrieved from get_frontend/get_frontend_legacy. | ||
1762 | */ | ||
1763 | dtv_get_frontend(fe, &cache_out, NULL); | ||
1710 | for (i = 0; i < tvps->num; i++) { | 1764 | for (i = 0; i < tvps->num; i++) { |
1711 | err = dtv_property_process_get(fe, tvp + i, file); | 1765 | err = dtv_property_process_get(fe, &cache_out, tvp + i, file); |
1712 | if (err < 0) | 1766 | if (err < 0) |
1713 | goto out; | 1767 | goto out; |
1714 | (tvp + i)->result = err; | 1768 | (tvp + i)->result = err; |
@@ -2008,10 +2062,10 @@ static int dvb_frontend_ioctl_legacy(struct file *file, | |||
2008 | break; | 2062 | break; |
2009 | 2063 | ||
2010 | case FE_GET_FRONTEND: | 2064 | case FE_GET_FRONTEND: |
2011 | if (fe->ops.get_frontend) { | 2065 | err = dtv_get_frontend(fe, NULL, &fepriv->parameters_out); |
2012 | err = fe->ops.get_frontend(fe, &fepriv->parameters_out); | 2066 | if (err >= 0) |
2013 | memcpy(parg, &fepriv->parameters_out, sizeof(struct dvb_frontend_parameters)); | 2067 | memcpy(parg, &fepriv->parameters_out, |
2014 | } | 2068 | sizeof(struct dvb_frontend_parameters)); |
2015 | break; | 2069 | break; |
2016 | 2070 | ||
2017 | case FE_SET_FRONTEND_TUNE_MODE: | 2071 | case FE_SET_FRONTEND_TUNE_MODE: |
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.h b/drivers/media/dvb/dvb-core/dvb_frontend.h index 1810bab1fb86..7a7debef53de 100644 --- a/drivers/media/dvb/dvb-core/dvb_frontend.h +++ b/drivers/media/dvb/dvb-core/dvb_frontend.h | |||
@@ -256,6 +256,8 @@ struct analog_demod_ops { | |||
256 | int (*set_config)(struct dvb_frontend *fe, void *priv_cfg); | 256 | int (*set_config)(struct dvb_frontend *fe, void *priv_cfg); |
257 | }; | 257 | }; |
258 | 258 | ||
259 | struct dtv_frontend_properties; | ||
260 | |||
259 | struct dvb_frontend_ops { | 261 | struct dvb_frontend_ops { |
260 | 262 | ||
261 | struct dvb_frontend_info info; | 263 | struct dvb_frontend_info info; |
@@ -284,7 +286,8 @@ struct dvb_frontend_ops { | |||
284 | int (*set_frontend)(struct dvb_frontend *fe); | 286 | int (*set_frontend)(struct dvb_frontend *fe); |
285 | int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings); | 287 | int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings); |
286 | 288 | ||
287 | int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params); | 289 | int (*get_frontend_legacy)(struct dvb_frontend *fe, struct dvb_frontend_parameters *params); |
290 | int (*get_frontend)(struct dvb_frontend *fe, struct dtv_frontend_properties *props); | ||
288 | 291 | ||
289 | int (*read_status)(struct dvb_frontend* fe, fe_status_t* status); | 292 | int (*read_status)(struct dvb_frontend* fe, fe_status_t* status); |
290 | int (*read_ber)(struct dvb_frontend* fe, u32* ber); | 293 | int (*read_ber)(struct dvb_frontend* fe, u32* ber); |