dvbsec_cfg.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /**
  2. * dvbsec_cfg (i.e. linuxtv SEC format) configuration file support.
  3. *
  4. * Copyright (c) 2006 by Andrew de Quincey <adq_dvb@lidskialf.net>
  5. *
  6. * This library is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as
  8. * published by the Free Software Foundation; either version 2.1 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. /**
  21. * This library allows SEC (Satellite Equipment Control) configurations
  22. * to be retrieved. Each configuration is identified by a unique satellite_id.
  23. *
  24. * In order to make things as easy as possible for users, there are a set of
  25. * defaults hardcoded into the library covering the majority of LNB types. When
  26. * these are used, the standard back-compatable sequence defined in the DISEQC
  27. * standard will be used - this will suffice for _most_ situations.
  28. *
  29. * UNIVERSAL - Europe, 10800 to 11800 MHz and 11600 to 12700 Mhz, Dual LO, loband 9750, hiband 10600 MHz.
  30. * DBS - Expressvu, North America, 12200 to 12700 MHz, Single LO, 11250 MHz.
  31. * STANDARD - 10945 to 11450 Mhz, Single LO, 10000Mhz.
  32. * ENHANCED - Astra, 10700 to 11700 MHz, Single LO, 9750MHz.
  33. * C-BAND - Big Dish, 3700 to 4200 MHz, Single LO, 5150Mhz.
  34. * C-MULTI - Big Dish - Multipoint LNBf, 3700 to 4200 MHz, Dual LO, H:5150MHz, V:5750MHz.
  35. *
  36. * However, for the power user with a more complex setup, these simple defaults
  37. * are not enough. Therefore, it is also possible to define additional SEC
  38. * configurations in an external configuration file. This file consists of multiple
  39. * entries in the following format:
  40. *
  41. * [sec]
  42. * name=<sec_id>
  43. * switch-frequency=<switching frequency (SLOF)>
  44. * lof-lo-v=<low band + V + frequency>
  45. * lof-lo-h=<low band + H + frequency>
  46. * lof-lo-l=<low band + L + frequency>
  47. * lof-lo-r=<low band + R + frequency>
  48. * lof-hi-v=<high band + V + frequency>
  49. * lof-hi-h=<high band + H + frequency>
  50. * lof-hi-l=<high band + L + frequency>
  51. * lof-hi-r=<high band + R + frequency>
  52. * config-type=<none|power|standard|advanced>
  53. * cmd-lo-v=<sec sequence>
  54. * cmd-lo-h=<sec sequence>
  55. * cmd-lo-r=<sec sequence>
  56. * cmd-lo-l=<sec sequence>
  57. * cmd-hi-v=<sec sequence>
  58. * cmd-hi-h=<sec sequence>
  59. * cmd-hi-r=<sec sequence>
  60. * cmd-hi-l=<sec sequence>
  61. *
  62. * The sec_id is whatever unique value you wish. If it is the same as one of the hardcoded defaults, the configuration
  63. * details from the file will be used instead of the hardcoded ones.
  64. * The switch-frequency (or SLOF) indicates the point seperating low band frequencies from high band frequencies.
  65. * Set this value to 0 if there is only one frequency band.
  66. * The lof-lo-v is the frequency adjustment for V + low band (i.e. less than SLOF), or is used if switch-frequency==0.
  67. * The lof-lo-h is the frequency adjustment for H + low band (i.e. less than SLOF), or is used if switch-frequency==0.
  68. * The lof-lo-l is the frequency adjustment for L + low band (i.e. less than SLOF), or is used if switch-frequency==0.
  69. * The lof-lo-r is the frequency adjustment for R + low band (i.e. less than SLOF), or is used if switch-frequency==0.
  70. * The lof-hi-v is the frequency adjustment for V + high band (unused if switch-frequency==0).
  71. * The lof-hi-h is the frequency adjustment for H + high band (unused if switch-frequency==0).
  72. * The lof-hi-l is the frequency adjustment for L + high band (unused if switch-frequency==0).
  73. * The lof-hi-r is the frequency adjustment for R + high band (unused if switch-frequency==0).
  74. *
  75. * config-type indicates the desired type of SEC command to use, it may be:
  76. * none - No SEC commands will be issued (frequency adjustment will still be performed).
  77. * power - Only the SEC power is turned on.
  78. * standard - The standard DISEQC back compatable sequence will be issued.
  79. * advanced - The DISEQC sequence described in the appropriate sec cmd string will be used.
  80. *
  81. * The cmd-<lo|hi>-<v|h|l|r> describes the SEC cmd string to use in advanced mode for each of the possible combinations of
  82. * frequency band and polarisation. If a certain combination is not required, it may be omitted. It consists of a
  83. * space seperated combination of commands - those available are as follows:
  84. *
  85. * tone(<0|1>) - control the 22kHz tone 0:off, 1:on
  86. * voltage(<0|13|18>) - control the LNB voltage 0v, 13v, or 18v
  87. * toneburst(<a|b>) - issue a toneburst (mini command) for position A or B.
  88. * highvoltage(<0|1>) - control high lnb voltage for long cable runs 0: normal, 1:add 1v to LNB voltage.
  89. * dishnetworks(<integer>) - issue a dishnetworks legacy command.
  90. * wait(<integer>) - wait for the given number of milliseconds.
  91. * Dreset(<address>, <0|1>) - control the reset state of a DISEC device, 0:disable reset, 1:enable reset.
  92. * Dpower(<address>, <0|1>) - control the power of a DISEC device, 0:off, 1:on.
  93. * Dcommitted(<address>, <h|l|x>, <v|h|l|r|x>, <a|b|x>, <a|b|x>) - Write to the committed switches of a DISEC device.
  94. * The parameters are for band, polarisation, satelliteposition, switchoption:
  95. * band - h:high band, l:low band
  96. * polarisation - v: vertical, h:horizontal,r:right,l:left
  97. * satelliteposition - a:position A, b: position B
  98. * switchoption - a:position A, b: position B
  99. * The special value 'x' means "no change to this switch".
  100. *
  101. * Duncommitted(<address>, <a|b|x>, <a|b|x>, <a|b|x>, <a|b|x>) - Write to the uncommitted switches of the a DISEC device.
  102. * The parameters are for switch1, switch2, switch3, switch4, and may be set to position a or b.
  103. * The special value 'x' means "no change to this switch".
  104. *
  105. * Dfrequency(<address>, <frequency in GHz>) - set the frequency of a DISEC device.
  106. * Dchannel(<address>, <channel id>) - set the desired channel id of a DISEC device.
  107. * Dgotopreset(<address>, <preset id>) - tell a DISEC satellite positioner to move to the given preset id.
  108. * Dgotobearing(<address>, <bearing in degrees>) - tell a DISEQC terrestrial rotator to go to the
  109. * given bearing (range -256.0 -> 512.0 degrees, fractions allowed).
  110. *
  111. * In the above DISEQC commands, <address> is the integer (normally in hex format) address of the
  112. * diseqc device to communicate with. A list of possiblities is as follows:
  113. *
  114. * DISEQC_ADDRESS_ANY_DEVICE = 0x00
  115. *
  116. * DISEQC_ADDRESS_ANY_LNB_SWITCHER_SMATV = 0x10
  117. * DISEQC_ADDRESS_LNB = 0x11
  118. * DISEQC_ADDRESS_LNB_WITH_LOOP = 0x12
  119. * DISEQC_ADDRESS_SWITCHER = 0x14
  120. * DISEQC_ADDRESS_SWITCHER_WITH_LOOP = 0x15
  121. * DISEQC_ADDRESS_SMATV = 0x18
  122. *
  123. * DISEQC_ADDRESS_ANY_POLARISER = 0x20
  124. * DISEQC_ADDRESS_LINEAR_POLARISER = 0x21
  125. *
  126. * DISEQC_ADDRESS_ANY_POSITIONER = 0x30
  127. * DISEQC_ADDRESS_POLAR_AZIMUTH_POSITIONER = 0x31
  128. * DISEQC_ADDRESS_ELEVATION_POSITIONER = 0x32
  129. *
  130. * DISEQC_ADDRESS_ANY_INSTALLER_AID = 0x40
  131. * DISEQC_ADDRESS_SIGNAL_STRENGTH = 0x41
  132. *
  133. * DISEQC_ADDRESS_ANY_INTERFACE = 0x70
  134. * DISEQC_ADDRESS_HEADEND_INTERFACE = 0x71
  135. *
  136. * DISEQC_ADDRESS_REALLOC_BASE = 0x60
  137. * DISEQC_ADDRESS_OEM_BASE = 0xf0
  138. */
  139. #ifndef DVBSEC_CFG_H
  140. #define DVBSEC_CFG_H 1
  141. #ifdef __cplusplus
  142. extern "C"
  143. {
  144. #endif
  145. #include <stdio.h>
  146. #include <stdint.h>
  147. #include <libdvbsec/dvbsec_api.h>
  148. /**
  149. * Callback function used in dvbsec_cfg_load().
  150. *
  151. * @param arg Private information to caller.
  152. * @param channel The current channel details.
  153. * @return 0 to continue, 1 to stop loading.
  154. */
  155. typedef int (*dvbsec_cfg_callback)(void *arg, struct dvbsec_config *sec);
  156. /**
  157. * Load an SEC file.
  158. *
  159. * @param f File to load from.
  160. * @param arg Value to pass to 'arg' in callback above.
  161. * @param cb Callback function called for each sec loaded from the file.
  162. * @return 0 on success, or nonzero error code on failure.
  163. */
  164. extern int dvbsec_cfg_load(FILE *f, void *arg,
  165. dvbsec_cfg_callback cb);
  166. /**
  167. * Convenience function to parse an SEC config file. This will also consult the set
  168. * of hardcoded defaults if no config file was supplied, or a match was not found in
  169. * the config file.
  170. *
  171. * @param config_file Config filename to load, or NULL to just check defaults.
  172. * @param sec_id ID of SEC configuration.
  173. * @param sec Where to put the details if found.
  174. * @return 0 on success, nonzero on error.
  175. */
  176. extern int dvbsec_cfg_find(const char *config_file,
  177. const char *sec_id,
  178. struct dvbsec_config *sec);
  179. /**
  180. * Save SEC format config file.
  181. *
  182. * @param f File to save to.
  183. * @param secs Pointer to array of SECs to save.
  184. * @param count Number of entries in the above array.
  185. * @return 0 on success, or nonzero error code on failure.
  186. */
  187. extern int dvbsec_cfg_save(FILE *f,
  188. struct dvbsec_config *secs,
  189. int count);
  190. #ifdef __cplusplus
  191. }
  192. #endif
  193. #endif