via_aux.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright 2011 Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public
  6. * License as published by the Free Software Foundation;
  7. * either version 2, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTIES OR REPRESENTATIONS; without even
  11. * the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. * A PARTICULAR PURPOSE.See the GNU General Public License
  13. * for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc.,
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. /*
  21. * infrastructure for devices connected via I2C
  22. */
  23. #include <linux/slab.h>
  24. #include "via_aux.h"
  25. struct via_aux_bus *via_aux_probe(struct i2c_adapter *adap)
  26. {
  27. struct via_aux_bus *bus;
  28. if (!adap)
  29. return NULL;
  30. bus = kmalloc(sizeof(*bus), GFP_KERNEL);
  31. if (!bus)
  32. return NULL;
  33. bus->adap = adap;
  34. INIT_LIST_HEAD(&bus->drivers);
  35. via_aux_edid_probe(bus);
  36. via_aux_vt1636_probe(bus);
  37. via_aux_vt1632_probe(bus);
  38. via_aux_vt1631_probe(bus);
  39. via_aux_vt1625_probe(bus);
  40. via_aux_vt1622_probe(bus);
  41. via_aux_vt1621_probe(bus);
  42. via_aux_sii164_probe(bus);
  43. via_aux_ch7301_probe(bus);
  44. return bus;
  45. }
  46. void via_aux_free(struct via_aux_bus *bus)
  47. {
  48. struct via_aux_drv *pos, *n;
  49. if (!bus)
  50. return;
  51. list_for_each_entry_safe(pos, n, &bus->drivers, chain) {
  52. if (pos->cleanup)
  53. pos->cleanup(pos);
  54. list_del(&pos->chain);
  55. kfree(pos->data);
  56. kfree(pos);
  57. }
  58. kfree(bus);
  59. }
  60. const struct fb_videomode *via_aux_get_preferred_mode(struct via_aux_bus *bus)
  61. {
  62. struct via_aux_drv *pos;
  63. const struct fb_videomode *mode = NULL;
  64. if (!bus)
  65. return NULL;
  66. list_for_each_entry(pos, &bus->drivers, chain) {
  67. if (pos->get_preferred_mode)
  68. mode = pos->get_preferred_mode(pos);
  69. }
  70. return mode;
  71. }