]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - include/media/v4l2-clk.h
Merge branch 'for-davem' of git://git.kernel.org/pub/scm/linux/kernel/git/linville...
[karo-tx-linux.git] / include / media / v4l2-clk.h
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
14 #ifndef MEDIA_V4L2_CLK_H
15 #define MEDIA_V4L2_CLK_H
16
17 #include <linux/atomic.h>
18 #include <linux/list.h>
19 #include <linux/mutex.h>
20
21 struct module;
22 struct device;
23
24 struct v4l2_clk {
25         struct list_head list;
26         const struct v4l2_clk_ops *ops;
27         const char *dev_id;
28         const char *id;
29         int enable;
30         struct mutex lock; /* Protect the enable count */
31         atomic_t use_count;
32         void *priv;
33 };
34
35 struct v4l2_clk_ops {
36         struct module   *owner;
37         int             (*enable)(struct v4l2_clk *clk);
38         void            (*disable)(struct v4l2_clk *clk);
39         unsigned long   (*get_rate)(struct v4l2_clk *clk);
40         int             (*set_rate)(struct v4l2_clk *clk, unsigned long);
41 };
42
43 struct v4l2_clk *v4l2_clk_register(const struct v4l2_clk_ops *ops,
44                                    const char *dev_name,
45                                    const char *name, void *priv);
46 void v4l2_clk_unregister(struct v4l2_clk *clk);
47 struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id);
48 void v4l2_clk_put(struct v4l2_clk *clk);
49 int v4l2_clk_enable(struct v4l2_clk *clk);
50 void v4l2_clk_disable(struct v4l2_clk *clk);
51 unsigned long v4l2_clk_get_rate(struct v4l2_clk *clk);
52 int v4l2_clk_set_rate(struct v4l2_clk *clk, unsigned long rate);
53
54 #endif