mantis_ca.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. Mantis PCI bridge driver
  3. Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #include "mantis_common.h"
  17. #include "mantis_link.h"
  18. #include "mantis_hif.h"
  19. static int mantis_ca_read_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr)
  20. {
  21. struct mantis_ca *ca = en50221->data;
  22. if (slot != 0)
  23. return -EINVAL;
  24. return mantis_hif_read_mem(ca, addr);
  25. }
  26. static int mantis_ca_write_attr_mem(struct dvb_ca_en50221 *en50221, int slot, int addr, u8 data)
  27. {
  28. struct mantis_ca *ca = en50221->data;
  29. if (slot != 0)
  30. return -EINVAL;
  31. return mantis_hif_write_mem(ca, addr, data);
  32. }
  33. static int mantis_ca_read_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr)
  34. {
  35. struct mantis_ca *ca = en50221->data;
  36. if (slot != 0)
  37. return -EINVAL;
  38. return mantis_hif_read_iom(ca, addr);
  39. }
  40. static int mantis_ca_write_cam_ctl(struct dvb_ca_en50221 *en50221, int slot, u8 addr, u8 data)
  41. {
  42. struct mantis_ca *ca = en50221->data;
  43. if (slot != 0)
  44. return -EINVAL;
  45. return mantis_hif_write_iom(ca, addr, data);
  46. }
  47. static int mantis_ca_slot_reset(struct dvb_ca_en50221 *en50221, int slot)
  48. {
  49. return 0;
  50. }
  51. static int mantis_ca_slot_shutdown(struct dvb_ca_en50221 *en50221, int slot)
  52. {
  53. return 0;
  54. }
  55. static int mantis_ts_control(struct dvb_ca_en50221 *en50221, int slot)
  56. {
  57. return 0;
  58. }
  59. static int mantis_slot_status(struct dvb_ca_en50221 *en50221, int slot, int open)
  60. {
  61. return 0;
  62. }
  63. int mantis_ca_init(struct mantis_pci *mantis)
  64. {
  65. struct dvb_adapter *dvb_adapter = &mantis->dvb_adapter;
  66. struct mantis_ca *ca;
  67. int ca_flags = 0, result;
  68. if (!(ca = kzalloc(sizeof (struct mantis_ca), GFP_KERNEL))) {
  69. dprintk(verbose, MANTIS_ERROR, 1, "Out of memory!, exiting ..");
  70. result = -ENOMEM;
  71. goto err;
  72. }
  73. ca->ca_priv = mantis;
  74. mantis->mantis_ca = ca;
  75. /* register CA interface */
  76. ca->en50221.owner = THIS_MODULE;
  77. ca->en50221.read_attribute_mem = mantis_ca_read_attr_mem;
  78. ca->en50221.write_attribute_mem = mantis_ca_write_attr_mem;
  79. ca->en50221.read_cam_control = mantis_ca_read_cam_ctl;
  80. ca->en50221.write_cam_control = mantis_ca_write_cam_ctl;
  81. ca->en50221.slot_reset = mantis_ca_slot_reset;
  82. ca->en50221.slot_shutdown = mantis_ca_slot_shutdown;
  83. ca->en50221.slot_ts_enable = mantis_ts_control;
  84. ca->en50221.poll_slot_status = mantis_slot_status;
  85. ca->en50221.data = ca;
  86. dprintk(verbose, MANTIS_ERROR, 1, "Registering EN50221 device");
  87. if ((result = dvb_ca_en50221_init(dvb_adapter, &ca->en50221, ca_flags, 1)) != 0) {
  88. dprintk(verbose, MANTIS_ERROR, 1, "EN50221: Initialization failed");
  89. goto err;
  90. }
  91. dprintk(verbose, MANTIS_ERROR, 1, "Registered EN50221 device");
  92. mantis_evmgr_init(ca);
  93. return 0;
  94. err:
  95. kfree(ca);
  96. return result;
  97. }
  98. void mantis_ca_exit(struct mantis_pci *mantis)
  99. {
  100. struct mantis_ca *ca = mantis->mantis_ca;
  101. mantis_evmgr_exit(ca);
  102. dprintk(verbose, MANTIS_ERROR, 1, "Unregistering EN50221 device");
  103. dvb_ca_en50221_release(&ca->en50221);
  104. kfree(ca);
  105. }