media: qcom: camss: Use common VFE pm_domain_on/pm_domain_off where applicable
For the various versions of VFE we have a boiler-plate
pm_domain_on/pm_domain_off callback pair of the general form.
- Error check.
Not always done but applicable to all.
- device_link_add (DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME |
DL_FLAG_RPM_ACTIVE);
- Error check returning -EINVAL on error.
- Return 0
Reduce the pattern down to a common callback. VFE 4.1 is a special case
which to me also indicates that it is worthwhile maintaining an indirection
for the vfe_pm_domain_{on|off} for now.
Otherwise lets chuck out a bunch of needlessly replicated code.
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Suggested-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Tested-by: Matti Lehtimäki <matti.lehtimaki@gmail.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
This commit is contained in:
committed by
Hans Verkuil
parent
a409b3f08d
commit
eb73facec2
@@ -627,41 +627,6 @@ out_unlock:
|
||||
spin_unlock_irqrestore(&vfe->output_lock, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_off - Disable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
static void vfe_pm_domain_off(struct vfe_device *vfe)
|
||||
{
|
||||
struct camss *camss = vfe->camss;
|
||||
|
||||
if (vfe->id >= camss->res->vfe_num)
|
||||
return;
|
||||
|
||||
device_link_del(vfe->genpd_link);
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_on - Enable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
static int vfe_pm_domain_on(struct vfe_device *vfe)
|
||||
{
|
||||
struct camss *camss = vfe->camss;
|
||||
|
||||
if (vfe->id >= camss->res->vfe_num)
|
||||
return 0;
|
||||
|
||||
vfe->genpd_link = device_link_add(camss->dev, vfe->genpd,
|
||||
DL_FLAG_STATELESS |
|
||||
DL_FLAG_PM_RUNTIME |
|
||||
DL_FLAG_RPM_ACTIVE);
|
||||
if (!vfe->genpd_link)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_queue_buffer - Add empty buffer
|
||||
* @vid: Video device structure
|
||||
|
||||
@@ -936,7 +936,7 @@ static irqreturn_t vfe_isr(int irq, void *dev)
|
||||
* vfe_pm_domain_off - Disable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
static void vfe_pm_domain_off(struct vfe_device *vfe)
|
||||
static void vfe_4_1_pm_domain_off(struct vfe_device *vfe)
|
||||
{
|
||||
/* nop */
|
||||
}
|
||||
@@ -945,7 +945,7 @@ static void vfe_pm_domain_off(struct vfe_device *vfe)
|
||||
* vfe_pm_domain_on - Enable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
static int vfe_pm_domain_on(struct vfe_device *vfe)
|
||||
static int vfe_4_1_pm_domain_on(struct vfe_device *vfe)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@@ -999,8 +999,8 @@ const struct vfe_hw_ops vfe_ops_4_1 = {
|
||||
.hw_version = vfe_hw_version,
|
||||
.isr_read = vfe_isr_read,
|
||||
.isr = vfe_isr,
|
||||
.pm_domain_off = vfe_pm_domain_off,
|
||||
.pm_domain_on = vfe_pm_domain_on,
|
||||
.pm_domain_off = vfe_4_1_pm_domain_off,
|
||||
.pm_domain_on = vfe_4_1_pm_domain_on,
|
||||
.reg_update_clear = vfe_reg_update_clear,
|
||||
.reg_update = vfe_reg_update,
|
||||
.subdev_init = vfe_subdev_init,
|
||||
|
||||
@@ -1103,37 +1103,6 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 *value0, u32 *value1)
|
||||
writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD);
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_off - Disable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
static void vfe_pm_domain_off(struct vfe_device *vfe)
|
||||
{
|
||||
if (!vfe)
|
||||
return;
|
||||
|
||||
device_link_del(vfe->genpd_link);
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_on - Enable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
static int vfe_pm_domain_on(struct vfe_device *vfe)
|
||||
{
|
||||
struct camss *camss = vfe->camss;
|
||||
|
||||
vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS |
|
||||
DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
|
||||
|
||||
if (!vfe->genpd_link) {
|
||||
dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vfe_violation_read(struct vfe_device *vfe)
|
||||
{
|
||||
u32 violation = readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS);
|
||||
|
||||
@@ -1093,34 +1093,6 @@ static void vfe_isr_read(struct vfe_device *vfe, u32 *value0, u32 *value1)
|
||||
writel_relaxed(VFE_0_IRQ_CMD_GLOBAL_CLEAR, vfe->base + VFE_0_IRQ_CMD);
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_off - Disable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
static void vfe_pm_domain_off(struct vfe_device *vfe)
|
||||
{
|
||||
device_link_del(vfe->genpd_link);
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_on - Enable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
static int vfe_pm_domain_on(struct vfe_device *vfe)
|
||||
{
|
||||
struct camss *camss = vfe->camss;
|
||||
|
||||
vfe->genpd_link = device_link_add(camss->dev, vfe->genpd, DL_FLAG_STATELESS |
|
||||
DL_FLAG_PM_RUNTIME | DL_FLAG_RPM_ACTIVE);
|
||||
|
||||
if (!vfe->genpd_link) {
|
||||
dev_err(vfe->camss->dev, "Failed to add VFE#%d to power domain\n", vfe->id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vfe_violation_read(struct vfe_device *vfe)
|
||||
{
|
||||
u32 violation = readl_relaxed(vfe->base + VFE_0_VIOLATION_STATUS);
|
||||
|
||||
@@ -452,41 +452,6 @@ out_unlock:
|
||||
spin_unlock_irqrestore(&vfe->output_lock, flags);
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_off - Disable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
static void vfe_pm_domain_off(struct vfe_device *vfe)
|
||||
{
|
||||
struct camss *camss = vfe->camss;
|
||||
|
||||
if (vfe->id >= camss->res->vfe_num)
|
||||
return;
|
||||
|
||||
device_link_del(vfe->genpd_link);
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_on - Enable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
static int vfe_pm_domain_on(struct vfe_device *vfe)
|
||||
{
|
||||
struct camss *camss = vfe->camss;
|
||||
|
||||
if (vfe->id >= camss->res->vfe_num)
|
||||
return 0;
|
||||
|
||||
vfe->genpd_link = device_link_add(camss->dev, vfe->genpd,
|
||||
DL_FLAG_STATELESS |
|
||||
DL_FLAG_PM_RUNTIME |
|
||||
DL_FLAG_RPM_ACTIVE);
|
||||
if (!vfe->genpd_link)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_queue_buffer - Add empty buffer
|
||||
* @vid: Video device structure
|
||||
|
||||
@@ -474,6 +474,40 @@ void vfe_isr_reset_ack(struct vfe_device *vfe)
|
||||
complete(&vfe->reset_complete);
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_off - Disable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
void vfe_pm_domain_off(struct vfe_device *vfe)
|
||||
{
|
||||
if (!vfe->genpd)
|
||||
return;
|
||||
|
||||
device_link_del(vfe->genpd_link);
|
||||
vfe->genpd_link = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_on - Enable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
int vfe_pm_domain_on(struct vfe_device *vfe)
|
||||
{
|
||||
struct camss *camss = vfe->camss;
|
||||
|
||||
if (!vfe->genpd)
|
||||
return 0;
|
||||
|
||||
vfe->genpd_link = device_link_add(camss->dev, vfe->genpd,
|
||||
DL_FLAG_STATELESS |
|
||||
DL_FLAG_PM_RUNTIME |
|
||||
DL_FLAG_RPM_ACTIVE);
|
||||
if (!vfe->genpd_link)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vfe_match_clock_names(struct vfe_device *vfe,
|
||||
struct camss_clock *clock)
|
||||
{
|
||||
|
||||
@@ -203,6 +203,18 @@ int vfe_reset(struct vfe_device *vfe);
|
||||
*/
|
||||
int vfe_disable(struct vfe_line *line);
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_off - Disable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
void vfe_pm_domain_off(struct vfe_device *vfe);
|
||||
|
||||
/*
|
||||
* vfe_pm_domain_on - Enable power domains specific to this VFE.
|
||||
* @vfe: VFE Device
|
||||
*/
|
||||
int vfe_pm_domain_on(struct vfe_device *vfe);
|
||||
|
||||
extern const struct vfe_hw_ops vfe_ops_4_1;
|
||||
extern const struct vfe_hw_ops vfe_ops_4_7;
|
||||
extern const struct vfe_hw_ops vfe_ops_4_8;
|
||||
|
||||
Reference in New Issue
Block a user