v4l2-clk.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * V4L2 clock service
  3. *
  4. * Copyright (C) 2012-2013, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * ATTENTION: This is a temporary API and it shall be replaced by the generic
  11. * clock API, when the latter becomes widely available.
  12. */
  13. #ifndef MEDIA_V4L2_CLK_H
  14. #define MEDIA_V4L2_CLK_H
  15. #include <linux/atomic.h>
  16. #include <linux/list.h>
  17. #include <linux/mutex.h>
  18. struct module;
  19. struct device;
  20. struct v4l2_clk {
  21. struct list_head list;
  22. const struct v4l2_clk_ops *ops;
  23. const char *dev_id;
  24. const char *id;
  25. int enable;
  26. struct mutex lock; /* Protect the enable count */
  27. atomic_t use_count;
  28. void *priv;
  29. };
  30. struct v4l2_clk_ops {
  31. struct module *owner;
  32. int (*enable)(struct v4l2_clk *clk);
  33. void (*disable)(struct v4l2_clk *clk);
  34. unsigned long (*get_rate)(struct v4l2_clk *clk);
  35. int (*set_rate)(struct v4l2_clk *clk, unsigned long);
  36. };
  37. struct v4l2_clk *v4l2_clk_register(const struct v4l2_clk_ops *ops,
  38. const char *dev_name,
  39. const char *name, void *priv);
  40. void v4l2_clk_unregister(struct v4l2_clk *clk);
  41. struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id);
  42. void v4l2_clk_put(struct v4l2_clk *clk);
  43. int v4l2_clk_enable(struct v4l2_clk *clk);
  44. void v4l2_clk_disable(struct v4l2_clk *clk);
  45. unsigned long v4l2_clk_get_rate(struct v4l2_clk *clk);
  46. int v4l2_clk_set_rate(struct v4l2_clk *clk, unsigned long rate);
  47. #endif