Commit d373018f authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

media: ti-vpe: cal: Move CAL I/O accessors to cal.h

To prepare for the split of the camerarx code to a separate file, move
the CAL I/O accessors to cal.h. This requires renaming the accessors
with a cal_prefix, as the current names are too generic and prone to
namespace clashes.

The reg_read() and read_write() macros, that cover both CAL and CAMERARX
register access, are split in two groups of inline functions, one for
CAL access and one for CAMERARX access.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarBenoit Parrot <bparrot@ti.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 9d551891
......@@ -9,7 +9,6 @@
* Laurent Pinchart <laurent.pinchart@ideasonboard.com>
*/
#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/ioctl.h>
#include <linux/pm_runtime.h>
......
This diff is collapsed.
......@@ -11,6 +11,8 @@
#ifndef __TI_CAL_H__
#define __TI_CAL_H__
#include <linux/bitfield.h>
#include <linux/io.h>
#include <linux/list.h>
#include <linux/mutex.h>
#include <linux/spinlock.h>
......@@ -203,6 +205,40 @@ extern int cal_video_nr;
#define phy_err(phy, fmt, arg...) \
cal_err((phy)->cal, "phy%u: " fmt, (phy)->instance, ##arg)
static inline u32 cal_read(struct cal_dev *cal, u32 offset)
{
return ioread32(cal->base + offset);
}
static inline void cal_write(struct cal_dev *cal, u32 offset, u32 val)
{
iowrite32(val, cal->base + offset);
}
static inline u32 cal_read_field(struct cal_dev *cal, u32 offset, u32 mask)
{
return FIELD_GET(mask, cal_read(cal, offset));
}
static inline void cal_write_field(struct cal_dev *cal, u32 offset, u32 value,
u32 mask)
{
u32 val = cal_read(cal, offset);
val &= ~mask;
val |= FIELD_PREP(mask, value);
cal_write(cal, offset, val);
}
static inline void cal_set_field(u32 *valp, u32 field, u32 mask)
{
u32 val = *valp;
val &= ~mask;
val |= (field << __ffs(mask)) & mask;
*valp = val;
}
void cal_quickdump_regs(struct cal_dev *cal);
int cal_camerarx_start(struct cal_camerarx *phy, const struct cal_fmt *fmt);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment