dvb-fe.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. /*
  2. * Copyright (c) 2011-2014 - Mauro Carvalho Chehab
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation version 2
  7. * of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  18. *
  19. */
  20. #ifndef _DVB_FE_H
  21. #define _DVB_FE_H
  22. #include <stdio.h>
  23. #include <errno.h>
  24. #include <stdint.h>
  25. #include <stdlib.h>
  26. #include <sys/types.h>
  27. #include <sys/stat.h>
  28. #include <fcntl.h>
  29. #include <sys/ioctl.h>
  30. #include <string.h>
  31. #include "dvb-frontend.h"
  32. #include "dvb-sat.h"
  33. #include "dvb-log.h"
  34. /**
  35. * @file dvb-fe.h
  36. * @ingroup frontend
  37. * @brief Provides interfaces to deal with DVB frontend.
  38. * @copyright GNU General Public License version 2 (GPLv2)
  39. * @author Mauro Carvalho Chehab
  40. *
  41. * The libdvbv5 API works with a set of key/value properties.
  42. * There are two types of properties:
  43. *
  44. * - The ones defined at the Kernel's frontent API, that are found at
  45. * /usr/include/linux/dvb/frontend.h (actually, it uses a local copy
  46. * of that file, stored at ./include/linux/dvb/frontend.h)
  47. *
  48. * - Some extra properties used by libdvbv5. Those can be found at
  49. * lib/include/libdvbv5/dvb-v5-std.h and start at DTV_USER_COMMAND_START.
  50. *
  51. * Just like the DTV properties, the stats are cached. That warrants that
  52. * all stats are got at the same time, when dvb_fe_get_stats() is called.
  53. *
  54. * @par Bug Report
  55. * Please submit bug reports and patches to linux-media@vger.kernel.org
  56. */
  57. /**
  58. * @def ARRAY_SIZE(array)
  59. * @brief Calculates the number of elements of an array
  60. * @ingroup ancillary
  61. */
  62. #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
  63. /**
  64. * @def MAX_DELIVERY_SYSTEMS
  65. * @brief Max number of delivery systems for a given frontend.
  66. * @ingroup frontend
  67. */
  68. #define MAX_DELIVERY_SYSTEMS 20
  69. #ifndef _DOXYGEN
  70. /*
  71. * There are a few aliases for other properties. Those are needed just
  72. * to avoid breaking apps that depend on the library but shoudn't be used
  73. * anymore on newer apps.
  74. */
  75. #define DTV_MAX_STATS DTV_NUM_STATS_PROPS
  76. #define DTV_SIGNAL_STRENGTH DTV_STAT_SIGNAL_STRENGTH
  77. #define DTV_SNR DTV_STAT_CNR
  78. #define DTV_UNCORRECTED_BLOCKS DTV_STAT_ERROR_BLOCK_COUNT
  79. #endif
  80. /**
  81. * @struct dvb_v5_fe_parms
  82. * @ingroup frontend
  83. * @brief Keeps data needed to handle the DVB frontend
  84. *
  85. * @param info Contains the DVB info properties (RO)
  86. * @param version Version of the Linux DVB API (RO)
  87. * @param has_v5_stats A value different than 0 indicates that the
  88. * frontend supports DVBv5 stats (RO)
  89. * @param current_sys Currently selected delivery system (RO)
  90. * @param num_systems Number of delivery systems (RO)
  91. * @param systems Delivery systems supported by the hardware (RO)
  92. * @param legacy_fe A value different than 0 indicates a legacy
  93. * Kernel driver using DVBv3 API only, or that
  94. * DVBv3 only mode was forced by the client (RO)
  95. * @param abort Client should set it to abort a pending
  96. * operation like DTV scan (RW)
  97. * @param lna: Sets the LNA mode 0 disables; 1 enables, -1 uses
  98. * auto mode (RW)
  99. * @param lnb LNBf description (RW)
  100. * @param sat_number Number of the satellite (used by DISEqC setup) (RW)
  101. * @param freq_bpf SCR/Unicable band-pass filter frequency to use, in kHz
  102. * @param verbose Verbosity level of the library (RW)
  103. * @param dvb_logfunc Function used to write log messages (RO)
  104. * @param default_charset Name of the charset used by the DVB standard (RW)
  105. * @param output_charset Name of the charset to output (system specific) (RW)
  106. *
  107. * @details The fields marked as RO should not be changed by the client, as otherwise
  108. * undesired effects may happen. The ones marked as RW are ok to either read
  109. * or write by the client.
  110. */
  111. struct dvb_v5_fe_parms {
  112. /* Information visible to the client - don't override those values */
  113. struct dvb_frontend_info info;
  114. uint32_t version;
  115. int has_v5_stats;
  116. fe_delivery_system_t current_sys;
  117. int num_systems;
  118. fe_delivery_system_t systems[MAX_DELIVERY_SYSTEMS];
  119. int legacy_fe;
  120. /* The values below are specified by the library client */
  121. /* Flags from the client to the library */
  122. int abort;
  123. /* Linear Amplifier settings */
  124. int lna;
  125. /* Satellite settings */
  126. const struct dvb_sat_lnb *lnb;
  127. int sat_number;
  128. unsigned freq_bpf;
  129. unsigned diseqc_wait;
  130. /* Function to write DVB logs */
  131. unsigned verbose;
  132. dvb_logfunc logfunc;
  133. /* Charsets to be used by the conversion utilities */
  134. char *default_charset;
  135. char *output_charset;
  136. };
  137. #ifdef __cplusplus
  138. extern "C" {
  139. #endif
  140. /**
  141. * @brief Allocates a dummy frontend structure
  142. * @ingroup frontend
  143. *
  144. * @details This is useful for some applications that may want to just use the
  145. * frontend structure internally, without associating it with a real hardware
  146. *
  147. * @return Returns a pointer to a dummy struct, or NULL if no memory.
  148. */
  149. struct dvb_v5_fe_parms *dvb_fe_dummy(void);
  150. /**
  151. * @brief Opens a frontend and allocates a structure to work with
  152. * @ingroup frontend
  153. *
  154. * @param adapter Number of the adapter to open
  155. * @param frontend Number of the frontend to open
  156. * @param verbose Verbosity level of the messages that will be
  157. * printed
  158. * @param use_legacy_call Force to use the DVBv3 calls, instead of using
  159. * the DVBv5 API
  160. * @param logfunc Callback function to be called when a log event
  161. * happens. Can either store the event into a file
  162. * or to print it at the TUI/GUI. If NULL, the
  163. * library will use its internal handler.
  164. * @param flags Flags to be passed to open. Currently only two
  165. * flags are supported: O_RDONLY or O_RDWR.
  166. * Using O_NONBLOCK may hit unexpected issues.
  167. *
  168. * @todo Add/check support for O_NONBLOCK at the scan routines.
  169. *
  170. * @details This function should be called before using any other function at
  171. * the frontend library (or the other alternatives: dvb_fe_open() or
  172. * dvb_fe_dummy().
  173. *
  174. * In general, this is called using O_RDWR, except if all that it is wanted
  175. * is to check the DVB frontend statistics.
  176. *
  177. * @return Returns a pointer to an allocated data pointer or NULL on error.
  178. */
  179. struct dvb_v5_fe_parms *dvb_fe_open_flags(int adapter, int frontend,
  180. unsigned verbose,
  181. unsigned use_legacy_call,
  182. dvb_logfunc logfunc,
  183. int flags);
  184. /**
  185. * @brief Opens a frontend and allocates a structure to work with
  186. * @ingroup frontend
  187. *
  188. * @param adapter Number of the adapter to open
  189. * @param frontend Number of the frontend to open
  190. * @param verbose Verbosity level of the messages that will be
  191. * printed
  192. * @param use_legacy_call Force to use the DVBv3 calls, instead of using
  193. * the DVBv5 API
  194. *
  195. * @details This function should be called before using any other function at
  196. * the frontend library (or the other alternatives: dvb_fe_open2() or
  197. * dvb_fe_dummy().
  198. *
  199. * @return Returns a pointer to an allocated data pointer or NULL on error.
  200. */
  201. struct dvb_v5_fe_parms *dvb_fe_open(int adapter, int frontend,
  202. unsigned verbose,
  203. unsigned use_legacy_call);
  204. /**
  205. * @brief Opens a frontend and allocates a structure to work with
  206. * @ingroup frontend
  207. *
  208. * @param adapter Number of the adapter to open
  209. * @param frontend Number of the frontend to open
  210. * @param verbose Verbosity level of the messages that will be
  211. * printed
  212. * @param use_legacy_call Force to use the DVBv3 calls, instead of using
  213. * the DVBv5 API
  214. * @param logfunc Callback function to be called when a log event
  215. * happens. Can either store the event into a file
  216. * or to print it at the TUI/GUI.
  217. *
  218. * @details This function should be called before using any other function at
  219. * the frontend library (or the other alternatives: dvb_fe_open() or
  220. * dvb_fe_dummy().
  221. *
  222. * @return Returns a pointer to an allocated data pointer or NULL on error.
  223. */
  224. struct dvb_v5_fe_parms *dvb_fe_open2(int adapter, int frontend,
  225. unsigned verbose, unsigned use_legacy_call,
  226. dvb_logfunc logfunc);
  227. /**
  228. * @brief Closes the frontend and frees allocated resources
  229. * @ingroup frontend
  230. *
  231. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  232. */
  233. void dvb_fe_close(struct dvb_v5_fe_parms *parms);
  234. /**
  235. * @brief Returns the string name associated with a DVBv5 command
  236. * @ingroup frontend
  237. *
  238. * @param cmd DVBv5 or libdvbv5 property
  239. *
  240. * @details This function gets an integer argument (cmd) and returns a string
  241. * that corresponds to the name of that property.
  242. *
  243. * @return it returns a string that corresponds to the property name.
  244. * For example:
  245. * dvb_cmd_name(DTV_GUARD_INTERVAL) would return "GUARD_INTERVAL"
  246. * It also returns names for the properties used internally by libdvbv5.
  247. */
  248. const char *dvb_cmd_name(int cmd);
  249. /**
  250. * @brief Returns an string array with the valid string values associated with a DVBv5 command
  251. * @ingroup frontend
  252. *
  253. * @param cmd DVBv5 or libdvbv5 property
  254. *
  255. * @return it returns a string array that corresponds to the names associated
  256. * with the possible values for that property, when available.
  257. * For example:
  258. * dvb_cmd_name(DTV_CODE_RATE_HP) would return an array with the
  259. * possible values for the code rates:
  260. * { "1/2", "2/3", ... NULL }
  261. * @note The array always ends with NULL.
  262. */
  263. const char *const *dvb_attr_names(int cmd);
  264. /* Get/set delivery system parameters */
  265. /**
  266. * @brief Retrieves the value of a DVBv5/libdvbv5 property
  267. * @ingroup frontend
  268. *
  269. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  270. * @param cmd DVBv5 or libdvbv5 property
  271. * @param value Pointer to an uint32_t where the value will be stored.
  272. *
  273. * This reads the value of a property stored at the cache. Before using it,
  274. * a dvb_fe_get_parms() is likely required.
  275. *
  276. * @return Return 0 if success, EINVAL otherwise.
  277. */
  278. int dvb_fe_retrieve_parm(const struct dvb_v5_fe_parms *parms,
  279. unsigned cmd, uint32_t *value);
  280. /**
  281. * @brief Stores the value of a DVBv5/libdvbv5 property
  282. * @ingroup frontend
  283. *
  284. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  285. * @param cmd DVBv5 or libdvbv5 property
  286. * @param value Pointer to an uint32_t where the value will be stored.
  287. *
  288. * This stores the value of a property at the cache. The value will only
  289. * be send to the hardware after calling dvb_fe_set_parms().
  290. *
  291. * @return Return 0 if success, EINVAL otherwise.
  292. */
  293. int dvb_fe_store_parm(struct dvb_v5_fe_parms *parms,
  294. unsigned cmd, uint32_t value);
  295. /**
  296. * @brief Sets the delivery system
  297. * @ingroup frontend
  298. *
  299. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  300. * @param sys delivery system to be selected
  301. *
  302. * This function changes the delivery system of the frontend. By default,
  303. * the libdvbv5 will use the first available delivery system. If another
  304. * delivery system is desirable, this function should be called before being
  305. * able to store the properties for the new delivery system via
  306. * dvb_fe_store_parm().
  307. *
  308. * @return Return 0 if success, EINVAL otherwise.
  309. */
  310. int dvb_set_sys(struct dvb_v5_fe_parms *parms,
  311. fe_delivery_system_t sys);
  312. /**
  313. * @brief Make dvb properties reflect the current standard
  314. * @ingroup frontend
  315. *
  316. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  317. * @param sys delivery system to be selected
  318. *
  319. * This function prepares the properties cache for a given delivery system.
  320. *
  321. * It is automatically called by dvb_set_sys(), and should not be normally
  322. * called, except when dvb_fe_dummy() is used.
  323. *
  324. * @return Return 0 if success, EINVAL otherwise.
  325. */
  326. int dvb_add_parms_for_sys(struct dvb_v5_fe_parms *parms,
  327. fe_delivery_system_t sys);
  328. /**
  329. * @brief Sets the delivery system
  330. * @ingroup frontend
  331. *
  332. * @param parms struct dvb_v5_fe_parms pointer to the opened
  333. * device
  334. * @param desired_system delivery system to be selected
  335. *
  336. * This function changes the delivery system of the frontend. By default,
  337. * the libdvbv5 will use the first available delivery system. If another
  338. * delivery system is desirable, this function should be called before being
  339. * able to store the properties for the new delivery system via
  340. * dvb_fe_store_parm().
  341. *
  342. * This function is an enhanced version of dvb_set_sys(). It has an special
  343. * logic inside to work with Kernels that supports only DVBv3.
  344. *
  345. * @return Return 0 if success, EINVAL otherwise.
  346. */
  347. int dvb_set_compat_delivery_system(struct dvb_v5_fe_parms *parms,
  348. uint32_t desired_system);
  349. /**
  350. * @brief Prints all the properties at the cache
  351. * @ingroup frontend
  352. *
  353. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  354. *
  355. * Used mostly for debugging issues.
  356. */
  357. void dvb_fe_prt_parms(const struct dvb_v5_fe_parms *parms);
  358. /**
  359. * @brief Prints all the properties at the cache
  360. * @ingroup frontend
  361. *
  362. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  363. *
  364. * Writes the properties stored at the DVB cache at the DVB hardware. At
  365. * return, some properties could have a different value, as the frontend
  366. * may not support the values set.
  367. *
  368. * @return Return 0 if success, EINVAL otherwise.
  369. */
  370. int dvb_fe_set_parms(struct dvb_v5_fe_parms *parms);
  371. /**
  372. * @brief Prints all the properties at the cache
  373. * @ingroup frontend
  374. *
  375. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  376. *
  377. * Gets the properties from the DVB hardware. The values will only reflect
  378. * what's set at the hardware if the frontend is locked.
  379. *
  380. * @return Return 0 if success, EINVAL otherwise.
  381. */
  382. int dvb_fe_get_parms(struct dvb_v5_fe_parms *parms);
  383. /*
  384. * statistics functions
  385. */
  386. /**
  387. * @brief Retrieve the stats for a DTV layer from cache
  388. * @ingroup frontend
  389. *
  390. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  391. * @param cmd DVBv5 or libdvbv5 property
  392. * @param layer DTV layer
  393. *
  394. * Gets the value for one stats cache, on a given layer. Layer 0 is
  395. * always present. On DTV standards that doesn't have layers, it returns
  396. * the same value as dvb_fe_retrieve_stats() for layer = 0.
  397. *
  398. * For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
  399. * layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
  400. * frontends support per-layer stats. Also, the layer value is only valid if
  401. * the layer exists at the original stream.
  402. * Also, on such standards, layer 0 is typically a mean value of the layers,
  403. * or a sum of events (if FE_SCALE_COUNTER).
  404. *
  405. * For it to be valid, dvb_fe_get_stats() should be called first.
  406. *
  407. * @return It returns a struct dtv_stats if succeed or NULL otherwise.
  408. */
  409. struct dtv_stats *dvb_fe_retrieve_stats_layer(struct dvb_v5_fe_parms *parms,
  410. unsigned cmd, unsigned layer);
  411. /**
  412. * @brief Retrieve the stats for a DTV layer from cache
  413. * @ingroup frontend
  414. *
  415. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  416. * @param cmd DVBv5 or libdvbv5 property
  417. * @param value DTV value pointer
  418. *
  419. * Gets the value for one stats property for layer = 0.
  420. *
  421. * For it to be valid, dvb_fe_get_stats() should be called first.
  422. *
  423. * @return The returned value is 0 if success, EINVAL otherwise.
  424. */
  425. int dvb_fe_retrieve_stats(struct dvb_v5_fe_parms *parms,
  426. unsigned cmd, uint32_t *value);
  427. /**
  428. * @brief Retrieve the stats from the Kernel
  429. * @ingroup frontend
  430. *
  431. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  432. *
  433. * Updates the stats cache from the available stats at the Kernel.
  434. *
  435. * @return The returned value is 0 if success, EINVAL otherwise.
  436. */
  437. int dvb_fe_get_stats(struct dvb_v5_fe_parms *parms);
  438. /**
  439. * @brief Retrieve the BER stats from cache
  440. * @ingroup frontend
  441. *
  442. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  443. * @param layer DTV layer
  444. * @param scale retrieves the scale
  445. *
  446. * Gets the value for BER stats from stats cache, on a given layer. Layer 0 is
  447. * always present. On DTV standards that doesn't have layers, it returns
  448. * the same value as dvb_fe_retrieve_stats() for layer = 0.
  449. *
  450. * For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
  451. * layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
  452. * frontends support per-layer stats. Also, the layer value is only valid if
  453. * the layer exists at the original stream.
  454. * Also, on such standards, layer 0 is typically a mean value of the layers,
  455. * or a sum of events (if FE_SCALE_COUNTER).
  456. *
  457. * For it to be valid, dvb_fe_get_stats() should be called first.
  458. *
  459. * @return It returns a float number for the BER value.
  460. * If the statistics is not available for any reason, scale will be equal to
  461. * FE_SCALE_NOT_AVAILABLE.
  462. */
  463. float dvb_fe_retrieve_ber(struct dvb_v5_fe_parms *parms, unsigned layer,
  464. enum fecap_scale_params *scale);
  465. /**
  466. * @brief Retrieve the PER stats from cache
  467. * @ingroup frontend
  468. *
  469. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  470. * @param layer DTV layer
  471. *
  472. * Gets the value for BER stats from stats cache, on a given layer. Layer 0 is
  473. * always present. On DTV standards that doesn't have layers, it returns
  474. * the same value as dvb_fe_retrieve_stats() for layer = 0.
  475. *
  476. * For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
  477. * layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
  478. * frontends support per-layer stats. Also, the layer value is only valid if
  479. * the layer exists at the original stream.
  480. * Also, on such standards, layer 0 is typically a mean value of the layers,
  481. * or a sum of events (if FE_SCALE_COUNTER).
  482. *
  483. * For it to be valid, dvb_fe_get_stats() should be called first.
  484. *
  485. * @return A negative value indicates error.
  486. */
  487. float dvb_fe_retrieve_per(struct dvb_v5_fe_parms *parms, unsigned layer);
  488. /**
  489. * @brief Retrieve the quality stats from cache
  490. * @ingroup frontend
  491. *
  492. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  493. * @param layer DTV layer
  494. *
  495. * Gets a quality measure for a given layer. Layer 0 is
  496. * always present. On DTV standards that doesn't have layers, it returns
  497. * the same value as dvb_fe_retrieve_stats() for layer = 0.
  498. *
  499. * For DTV standards with multiple layers, like ISDB, layer=1 is layer 'A',
  500. * layer=2 is layer 'B' and layer=3 is layer 'C'. Please notice that not all
  501. * frontends support per-layer stats. Also, the layer value is only valid if
  502. * the layer exists at the original stream.
  503. * Also, on such standards, layer 0 is typically a mean value of the layers,
  504. * or a sum of events (if FE_SCALE_COUNTER).
  505. *
  506. * For it to be valid, dvb_fe_get_stats() should be called first.
  507. *
  508. * @return returns an enum dvb_quantity, where DVB_QUAL_UNKNOWN means that
  509. * the stat isnot available.
  510. */
  511. enum dvb_quality dvb_fe_retrieve_quality(struct dvb_v5_fe_parms *parms,
  512. unsigned layer);
  513. /**
  514. * @brief Ancillary function to sprintf on ENG format
  515. * @ingroup frontend
  516. *
  517. * @param buf buffer to store the value
  518. * @param len buffer length
  519. * @param val value to be printed
  520. *
  521. * On ENG notation, the exponential value should be multiple of 3. This is
  522. * good to display some values, like BER.
  523. *
  524. * @return At return, it shows the actual size of the print. A negative value
  525. * indicates an error.
  526. */
  527. int dvb_fe_snprintf_eng(char *buf, int len, float val);
  528. /**
  529. * @brief Ancillary function to sprintf on ENG format
  530. * @ingroup frontend
  531. *
  532. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  533. * @param cmd DVBv5 or libdvbv5 property
  534. * @param display_name String with the name of the property to be shown
  535. * @param layer DTV Layer
  536. * @param buf buffer to store the value
  537. * @param len buffer length
  538. * @param show_layer_name a value different than zero shows the layer name, if
  539. * the layer is bigger than zero.
  540. *
  541. * This function calls internally dvb_fe_retrieve_stats_layer(). It allows to
  542. * print a DVBv5 statistics value into a string. An extra property is available
  543. * (DTV_QUALITY) with prints either one of the values: Poor, Ok or Good,
  544. * depending on the overall measures.
  545. *
  546. * @return: It returns the length of the printed data. A negative value
  547. * indicates an error.
  548. */
  549. int dvb_fe_snprintf_stat(struct dvb_v5_fe_parms *parms, uint32_t cmd,
  550. char *display_name, int layer,
  551. char **buf, int *len, int *show_layer_name);
  552. /**
  553. * @brief Get both status statistics and dvb parameters
  554. * @ingroup frontend
  555. *
  556. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  557. *
  558. * That's similar of calling both dvb_fe_get_parms() and dvb_fe_get_stats().
  559. *
  560. * @return It returns 0 if success or an errorno otherwise.
  561. */
  562. int dvb_fe_get_event(struct dvb_v5_fe_parms *parms);
  563. /*
  564. * Other functions, associated to SEC/LNB/DISEqC
  565. *
  566. * The functions below are just wrappers for the Kernel calls, in order to
  567. * manually control satellite systems.
  568. *
  569. * Instead of using most them, the best is to set the LNBf parameters, and let
  570. * the libdvbv5 to automatically handle the calls.
  571. *
  572. * NOTE: It currently lacks support for two ioctl's:
  573. * FE_DISEQC_RESET_OVERLOAD used only on av7110.
  574. * Spec says:
  575. * If the bus has been automatically powered off due to power overload,
  576. * this ioctl call restores the power to the bus. The call requires read/write
  577. * access to the device. This call has no effect if the device is manually
  578. * powered off. Not all DVB adapters support this ioctl.
  579. *
  580. * FE_DISHNETWORK_SEND_LEGACY_CMD is used on av7110, budget, gp8psk and stv0299
  581. * Spec says:
  582. * WARNING: This is a very obscure legacy command, used only at stv0299
  583. * driver. Should not be used on newer drivers.
  584. * It provides a non-standard method for selecting Diseqc voltage on the
  585. * frontend, for Dish Network legacy switches.
  586. * As support for this ioctl were added in 2004, this means that such dishes
  587. * were already legacy in 2004.
  588. *
  589. * So, it doesn't make much sense on implementing support for them.
  590. */
  591. /**
  592. * @brief DVB ioctl wrapper for setting SEC voltage
  593. * @ingroup frontend
  594. *
  595. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  596. * @param on a value different than zero indicates to enable
  597. * voltage on a Satellite Equipment Control (SEC)
  598. * @param v18 if on != 0, a value different than zero means 18 Volts;
  599. * zero means 13 Volts.
  600. *
  601. * If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
  602. */
  603. int dvb_fe_sec_voltage(struct dvb_v5_fe_parms *parms, int on, int v18);
  604. /**
  605. * @brief DVB ioctl wrapper for setting SEC tone
  606. * @ingroup frontend
  607. *
  608. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  609. * @param tone tone setting, as defined by DVB fe_sec_tone_mode_t type
  610. *
  611. * If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
  612. */
  613. int dvb_fe_sec_tone(struct dvb_v5_fe_parms *parms, fe_sec_tone_mode_t tone);
  614. /**
  615. * @brief DVB ioctl wrapper for setting LNBf high voltage
  616. * @ingroup frontend
  617. *
  618. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  619. * @param on a value different than zero indicates to produce
  620. * lightly higher voltages instead of 13/18V, in order
  621. * to compensate for long cables.
  622. */
  623. int dvb_fe_lnb_high_voltage(struct dvb_v5_fe_parms *parms, int on);
  624. /**
  625. * @brief DVB ioctl wrapper for setting SEC DiSeqC tone burst to select between
  626. * satellite A or B
  627. * @ingroup frontend
  628. *
  629. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  630. * @param mini_b if different than zero, sends a 22 KHz tone burst to
  631. * select satellite B. Otherwise, sends tone to select
  632. * satellite A.
  633. *
  634. * Valid only on certain DISEqC arrangements.
  635. *
  636. * If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
  637. */
  638. int dvb_fe_diseqc_burst(struct dvb_v5_fe_parms *parms, int mini_b);
  639. /**
  640. * @brief DVB ioctl wrapper for setting SEC DiSeqC command
  641. * @ingroup frontend
  642. *
  643. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  644. * @param len size of the DiSEqC command
  645. * @param buf DiSEqC command to be sent
  646. *
  647. * If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
  648. */
  649. int dvb_fe_diseqc_cmd(struct dvb_v5_fe_parms *parms, const unsigned len,
  650. const unsigned char *buf);
  651. /**
  652. * @brief DVB ioctl wrapper for getting SEC DiSEqC reply
  653. * @ingroup frontend
  654. *
  655. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  656. * @param len size of the DiSEqC command
  657. * @param buf DiSEqC command to be sent
  658. * @param timeout maximum time to receive the command, in ms.
  659. *
  660. * If dvb_v5_fe_parms::lnb is set, this is controlled automatically.
  661. */
  662. int dvb_fe_diseqc_reply(struct dvb_v5_fe_parms *parms, unsigned *len, char *buf,
  663. int timeout);
  664. /**
  665. * @brief DVB Ancillary routine to check if a given Delivery system is satellite
  666. * @ingroup frontend
  667. *
  668. * @param delivery_system delivery system to be selected
  669. */
  670. int dvb_fe_is_satellite(uint32_t delivery_system);
  671. /**
  672. * @brief Set default country variant of delivery systems like ISDB-T
  673. * @ingroup frontend
  674. *
  675. * @param parms struct dvb_v5_fe_parms pointer to the opened device
  676. * @param country default country, in ISO 3166-1 two letter code. If
  677. * NULL, default charset is guessed from locale environment
  678. * variables.
  679. *
  680. * @return 0 if success or an errorno otherwise.
  681. *
  682. * "COUNTRY" property in dvb_fe_set_parm() overrides the setting.
  683. */
  684. int dvb_fe_set_default_country(struct dvb_v5_fe_parms *parms,
  685. const char *country);
  686. #ifdef __cplusplus
  687. }
  688. #endif
  689. /*
  690. * Arrays from dvb-v5.h
  691. *
  692. * Those arrays can be used to translate from a DVB property into a name.
  693. *
  694. * No need to directly access them from userspace, as dvb_attr_names()
  695. * already handles them into a more standard way.
  696. */
  697. #ifndef _DOXYGEN
  698. extern const unsigned fe_bandwidth_name[8];
  699. extern const char *dvb_v5_name[71];
  700. extern const void *dvb_v5_attr_names[];
  701. extern const char *delivery_system_name[20];
  702. extern const char *fe_code_rate_name[14];
  703. extern const char *fe_modulation_name[15];
  704. extern const char *fe_transmission_mode_name[10];
  705. extern const unsigned fe_bandwidth_name[8];
  706. extern const char *fe_guard_interval_name[12];
  707. extern const char *fe_hierarchy_name[6];
  708. extern const char *fe_voltage_name[4];
  709. extern const char *fe_tone_name[3];
  710. extern const char *fe_inversion_name[4];
  711. extern const char *fe_pilot_name[4];
  712. extern const char *fe_rolloff_name[5];
  713. #endif
  714. #endif