4 * Copyright (C) 2012-2013, Guennadi Liakhovetski <g.liakhovetski@gmx.de>
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.
10 * ATTENTION: This is a temporary API and it shall be replaced by the generic
11 * clock API, when the latter becomes widely available.
14 #ifndef MEDIA_V4L2_CLK_H
15 #define MEDIA_V4L2_CLK_H
17 #include <linux/atomic.h>
18 #include <linux/export.h>
19 #include <linux/list.h>
20 #include <linux/mutex.h>
26 struct list_head list
;
27 const struct v4l2_clk_ops
*ops
;
31 struct mutex lock
; /* Protect the enable count */
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);
44 struct v4l2_clk
*v4l2_clk_register(const struct v4l2_clk_ops
*ops
,
46 const char *name
, void *priv
);
47 void v4l2_clk_unregister(struct v4l2_clk
*clk
);
48 struct v4l2_clk
*v4l2_clk_get(struct device
*dev
, const char *id
);
49 void v4l2_clk_put(struct v4l2_clk
*clk
);
50 int v4l2_clk_enable(struct v4l2_clk
*clk
);
51 void v4l2_clk_disable(struct v4l2_clk
*clk
);
52 unsigned long v4l2_clk_get_rate(struct v4l2_clk
*clk
);
53 int v4l2_clk_set_rate(struct v4l2_clk
*clk
, unsigned long rate
);
57 struct v4l2_clk
*__v4l2_clk_register_fixed(const char *dev_id
,
58 const char *id
, unsigned long rate
, struct module
*owner
);
59 void v4l2_clk_unregister_fixed(struct v4l2_clk
*clk
);
61 static inline struct v4l2_clk
*v4l2_clk_register_fixed(const char *dev_id
,
65 return __v4l2_clk_register_fixed(dev_id
, id
, rate
, THIS_MODULE
);
68 #define v4l2_clk_name_i2c(name, size, adap, client) snprintf(name, size, \
69 "%d-%04x", adap, client)