Merge branch 'csum_fixes'
[linux-2.6-block.git] / include / media / v4l2-clk.h
CommitLineData
ff5430de
GL
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>
cf326dfe 18#include <linux/export.h>
ff5430de
GL
19#include <linux/list.h>
20#include <linux/mutex.h>
21
22struct module;
23struct device;
24
25struct v4l2_clk {
26 struct list_head list;
27 const struct v4l2_clk_ops *ops;
28 const char *dev_id;
29 const char *id;
30 int enable;
31 struct mutex lock; /* Protect the enable count */
32 atomic_t use_count;
33 void *priv;
34};
35
36struct v4l2_clk_ops {
37 struct module *owner;
38 int (*enable)(struct v4l2_clk *clk);
39 void (*disable)(struct v4l2_clk *clk);
40 unsigned long (*get_rate)(struct v4l2_clk *clk);
41 int (*set_rate)(struct v4l2_clk *clk, unsigned long);
42};
43
44struct v4l2_clk *v4l2_clk_register(const struct v4l2_clk_ops *ops,
45 const char *dev_name,
46 const char *name, void *priv);
47void v4l2_clk_unregister(struct v4l2_clk *clk);
48struct v4l2_clk *v4l2_clk_get(struct device *dev, const char *id);
49void v4l2_clk_put(struct v4l2_clk *clk);
50int v4l2_clk_enable(struct v4l2_clk *clk);
51void v4l2_clk_disable(struct v4l2_clk *clk);
52unsigned long v4l2_clk_get_rate(struct v4l2_clk *clk);
53int v4l2_clk_set_rate(struct v4l2_clk *clk, unsigned long rate);
54
cf326dfe
GL
55struct module;
56
57struct v4l2_clk *__v4l2_clk_register_fixed(const char *dev_id,
58 const char *id, unsigned long rate, struct module *owner);
59void v4l2_clk_unregister_fixed(struct v4l2_clk *clk);
60
61static inline struct v4l2_clk *v4l2_clk_register_fixed(const char *dev_id,
62 const char *id,
63 unsigned long rate)
64{
65 return __v4l2_clk_register_fixed(dev_id, id, rate, THIS_MODULE);
66}
67
774cc4c2
GL
68#define v4l2_clk_name_i2c(name, size, adap, client) snprintf(name, size, \
69 "%d-%04x", adap, client)
70
ff5430de 71#endif