aci.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef _ACI_H_
  2. #define _ACI_H_
  3. extern int aci_port;
  4. extern int aci_version; /* ACI firmware version */
  5. extern int aci_rw_cmd(int write1, int write2, int write3);
  6. #define aci_indexed_cmd(a, b) aci_rw_cmd(a, b, -1)
  7. #define aci_write_cmd(a, b) aci_rw_cmd(a, b, -1)
  8. #define aci_read_cmd(a) aci_rw_cmd(a,-1, -1)
  9. #define COMMAND_REGISTER (aci_port) /* write register */
  10. #define STATUS_REGISTER (aci_port + 1) /* read register */
  11. #define BUSY_REGISTER (aci_port + 2) /* also used for rds */
  12. #define RDS_REGISTER BUSY_REGISTER
  13. #define ACI_SET_MUTE 0x0d
  14. #define ACI_SET_POWERAMP 0x0f
  15. #define ACI_SET_TUNERMUTE 0xa3
  16. #define ACI_SET_TUNERMONO 0xa4
  17. #define ACI_SET_IDE 0xd0
  18. #define ACI_SET_WSS 0xd1
  19. #define ACI_SET_SOLOMODE 0xd2
  20. #define ACI_WRITE_IGAIN 0x03
  21. #define ACI_WRITE_TUNE 0xa7
  22. #define ACI_READ_TUNERSTEREO 0xa8
  23. #define ACI_READ_TUNERSTATION 0xa9
  24. #define ACI_READ_VERSION 0xf1
  25. #define ACI_READ_IDCODE 0xf2
  26. #define ACI_INIT 0xff
  27. #define ACI_STATUS 0xf0
  28. #define ACI_S_GENERAL 0x00
  29. #define ACI_S_READ_IGAIN 0x21
  30. #define ACI_ERROR_OP 0xdf
  31. /*
  32. * The following macro SCALE can be used to scale one integer volume
  33. * value into another one using only integer arithmetic. If the input
  34. * value x is in the range 0 <= x <= xmax, then the result will be in
  35. * the range 0 <= SCALE(xmax,ymax,x) <= ymax.
  36. *
  37. * This macro has for all xmax, ymax > 0 and all 0 <= x <= xmax the
  38. * following nice properties:
  39. *
  40. * - SCALE(xmax,ymax,xmax) = ymax
  41. * - SCALE(xmax,ymax,0) = 0
  42. * - SCALE(xmax,ymax,SCALE(ymax,xmax,SCALE(xmax,ymax,x))) = SCALE(xmax,ymax,x)
  43. *
  44. * In addition, the rounding error is minimal and nicely distributed.
  45. * The proofs are left as an exercise to the reader.
  46. */
  47. #define SCALE(xmax,ymax,x) (((x)*(ymax)+(xmax)/2)/(xmax))
  48. #endif /* _ACI_H_ */