Optimize kernel-to-userspace battery life across CAMSS, SPI runtime PM, dwm, NeoUI, and plugins
This commit is contained in:
1 parent
f112b6ae72
commit
456d3fbc42
61 files changed
+466
-148
No files matched your search
@@ -400,6 +400,49 @@ static void msm8905_cam_enable_clocks(struct msm8905_cam_dev *cam)
|
||||
}
|
||||
}
|
||||
|
||||
static void msm8905_cam_hw_deinit(struct msm8905_cam_dev *cam)
|
||||
{
|
||||
ssize_t i;
|
||||
|
||||
if (!cam->hw_initialized)
|
||||
return;
|
||||
|
||||
/* 1. Stop ISPIF and sensor MIPI CSI-2 stream */
|
||||
cam_w32(cam->camss_base, ISPIF_BASE + 0x248U, 0xaaaaaaaaU);
|
||||
wmb();
|
||||
gc23xx_stream_off(cam);
|
||||
usleep_range(600, 900);
|
||||
|
||||
/* 2. Place sensor in hardware power-down and disable MCLK0 output */
|
||||
cam_gpio_out(cam, GPIO_CAM_RESET, false);
|
||||
cam_gpio_out(cam, GPIO_CAM_STANDBY, false);
|
||||
cam_gpio_out(cam, GPIO_CAM_VDIG, false);
|
||||
cam_gpio_cfg(cam, GPIO_CAM_MCLK0, 0x0001U);
|
||||
|
||||
/* 3. Gate CAMSS branch clocks in reverse order */
|
||||
for (i = (ssize_t)ARRAY_SIZE(camss_cbcr_offsets) - 1; i >= 0; i--) {
|
||||
u32 off = camss_cbcr_offsets[i];
|
||||
cam_w32(cam->gcc_base, off, cam_r32(cam->gcc_base, off) & ~1U);
|
||||
}
|
||||
wmb();
|
||||
|
||||
/* 4. Gate CAMSS RCG roots (MCLK0 and CSI/VFE RCGs) */
|
||||
cam_w32(cam->gcc_base, 0x52000U, 0x0U);
|
||||
cam_w32(cam->gcc_base, 0x4e000U, 0x0U);
|
||||
cam_w32(cam->gcc_base, 0x4f020U, 0x0U);
|
||||
cam_w32(cam->gcc_base, 0x4e020U, 0x0U);
|
||||
cam_w32(cam->gcc_base, 0x58000U, 0x0U);
|
||||
cam_w32(cam->gcc_base, 0x5a000U, 0x0U);
|
||||
|
||||
/* 5. Release SMMU vote clocks and power down VFE GDSC */
|
||||
cam_w32(cam->gcc_base, 0x4500cU, cam_r32(cam->gcc_base, 0x4500cU) & ~0x3202U);
|
||||
cam_w32(cam->gcc_base, 0x58034U, cam_r32(cam->gcc_base, 0x58034U) | 1U);
|
||||
wmb();
|
||||
|
||||
cam->hw_initialized = false;
|
||||
cam->streaming = false;
|
||||
}
|
||||
|
||||
static int msm8905_cam_hw_init(struct msm8905_cam_dev *cam)
|
||||
{
|
||||
size_t i;
|
||||
@@ -921,6 +964,7 @@ static int msm8905_cam_streamoff(struct file *file, void *priv,
|
||||
cam->streaming = false;
|
||||
for (idx = 0; idx < CAM_MAX_MMAP_BUFS; idx++)
|
||||
cam->buf_queued[idx] = false;
|
||||
msm8905_cam_hw_deinit(cam);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -994,10 +1038,29 @@ static __poll_t msm8905_cam_poll(struct file *file, poll_table *wait)
|
||||
return EPOLLIN | EPOLLRDNORM;
|
||||
}
|
||||
|
||||
static int msm8905_cam_release(struct file *file)
|
||||
{
|
||||
struct msm8905_cam_dev *cam = video_drvdata(file);
|
||||
bool is_last;
|
||||
u32 idx;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&cam->lock);
|
||||
is_last = v4l2_fh_is_singular_file(file);
|
||||
ret = v4l2_fh_release(file);
|
||||
if (is_last) {
|
||||
for (idx = 0; idx < CAM_MAX_MMAP_BUFS; idx++)
|
||||
cam->buf_queued[idx] = false;
|
||||
msm8905_cam_hw_deinit(cam);
|
||||
}
|
||||
mutex_unlock(&cam->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct v4l2_file_operations msm8905_cam_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = v4l2_fh_open,
|
||||
.release = v4l2_fh_release,
|
||||
.release = msm8905_cam_release,
|
||||
.read = msm8905_cam_read,
|
||||
.mmap = msm8905_cam_mmap,
|
||||
.poll = msm8905_cam_poll,
|
||||
@@ -1135,6 +1198,7 @@ static void __exit msm8905_cam_exit(void)
|
||||
|
||||
video_unregister_device(&cam->vdev);
|
||||
v4l2_device_unregister(&cam->v4l2_dev);
|
||||
msm8905_cam_hw_deinit(cam);
|
||||
iounmap(cam->vbif_base);
|
||||
iounmap(cam->camss_base);
|
||||
iounmap(cam->tlmm_base);
|
||||
|
||||
Reference in new issue
Block a user