pvrusb2-i2c-core.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. *
  3. * $Id$
  4. *
  5. * Copyright (C) 2005 Mike Isely <isely@pobox.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License
  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 General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. */
  21. #ifndef __PVRUSB2_I2C_CORE_H
  22. #define __PVRUSB2_I2C_CORE_H
  23. #include <linux/list.h>
  24. #include <linux/i2c.h>
  25. struct pvr2_hdw;
  26. struct pvr2_i2c_client;
  27. struct pvr2_i2c_handler;
  28. struct pvr2_i2c_handler_functions;
  29. struct pvr2_i2c_op;
  30. struct pvr2_i2c_op_functions;
  31. struct pvr2_i2c_client {
  32. struct i2c_client *client;
  33. struct pvr2_i2c_handler *handler;
  34. struct list_head list;
  35. int detected_flag;
  36. int recv_enable;
  37. unsigned long pend_mask;
  38. unsigned long ctl_mask;
  39. };
  40. struct pvr2_i2c_handler {
  41. void *func_data;
  42. const struct pvr2_i2c_handler_functions *func_table;
  43. };
  44. struct pvr2_i2c_handler_functions {
  45. void (*detach)(void *);
  46. int (*check)(void *);
  47. void (*update)(void *);
  48. unsigned int (*describe)(void *,char *,unsigned int);
  49. };
  50. struct pvr2_i2c_op {
  51. int (*check)(struct pvr2_hdw *);
  52. void (*update)(struct pvr2_hdw *);
  53. const char *name;
  54. };
  55. void pvr2_i2c_core_init(struct pvr2_hdw *);
  56. void pvr2_i2c_core_done(struct pvr2_hdw *);
  57. int pvr2_i2c_client_cmd(struct pvr2_i2c_client *,unsigned int cmd,void *arg);
  58. int pvr2_i2c_core_cmd(struct pvr2_hdw *,unsigned int cmd,void *arg);
  59. int pvr2_i2c_core_check_stale(struct pvr2_hdw *);
  60. void pvr2_i2c_core_sync(struct pvr2_hdw *);
  61. unsigned int pvr2_i2c_report(struct pvr2_hdw *,char *buf,unsigned int maxlen);
  62. #define PVR2_I2C_DETAIL_DEBUG 0x0001
  63. #define PVR2_I2C_DETAIL_HANDLER 0x0002
  64. #define PVR2_I2C_DETAIL_CTLMASK 0x0004
  65. #define PVR2_I2C_DETAIL_ALL (\
  66. PVR2_I2C_DETAIL_DEBUG |\
  67. PVR2_I2C_DETAIL_HANDLER |\
  68. PVR2_I2C_DETAIL_CTLMASK)
  69. void pvr2_i2c_probe(struct pvr2_hdw *,struct pvr2_i2c_client *);
  70. const struct pvr2_i2c_op *pvr2_i2c_get_op(unsigned int idx);
  71. #endif /* __PVRUSB2_I2C_CORE_H */
  72. /*
  73. Stuff for Emacs to see, in order to encourage consistent editing style:
  74. *** Local Variables: ***
  75. *** mode: c ***
  76. *** fill-column: 75 ***
  77. *** tab-width: 8 ***
  78. *** c-basic-offset: 8 ***
  79. *** End: ***
  80. */