Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6ce448d7 authored by Alan Kwong's avatar Alan Kwong
Browse files

msm: sde: update v4l2 rotator for kernel 4.9



This patch updates v4l2 rotator according to kernel 4.9 upgrade:
- update v4l2 vb2_op.queue_setup parameter list
- update v4l2 vb2_mem_op.get_userptr parameter list
- update dma_buf_begin/end_cpu_access parameter list

CRs-Fixed: 2009709
Change-Id: Ie3e3070e9d14d5aaaca781c793d5d44c99edf48a
Signed-off-by: default avatarAlan Kwong <akwong@codeaurora.org>
parent e1947ab9
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@
#include <linux/regulator/consumer.h>
#include <linux/dma-direction.h>
#include <soc/qcom/scm.h>
#include <soc/qcom/rpm-smd.h>
#include <soc/qcom/secure_buffer.h>
#include <asm/cacheflush.h>

@@ -45,6 +44,10 @@
/* Rotator device id to be used in SCM call */
#define SDE_ROTATOR_DEVICE	21

#ifndef VMID_CP_CAMERA_PREVIEW
#define VMID_CP_CAMERA_PREVIEW	VMID_INVAL
#endif

/* SCM call function id to be used for switching between secure and non
 * secure context
 */
@@ -255,7 +258,7 @@ static void sde_rotator_set_clk_rate(struct sde_rot_mgr *mgr,
			SDEROT_ERR("unable to round rate err=%ld\n", clk_rate);
		} else {
			ret = clk_set_rate(clk, clk_rate);
			if (IS_ERR_VALUE(ret))
			if (ret < 0)
				SDEROT_ERR("clk_set_rate failed, err:%d\n",
						ret);
			else
@@ -634,7 +637,7 @@ static int sde_rotator_map_and_check_data(struct sde_rot_entry *entry)
	rotation = (entry->item.flags &  SDE_ROTATION_90) ? true : false;

	ret = sde_smmu_ctrl(1);
	if (IS_ERR_VALUE(ret))
	if (ret < 0)
		return ret;

	secure = (entry->item.flags & SDE_ROTATION_SECURE_CAMERA) ?
@@ -1414,7 +1417,7 @@ static void sde_rotator_commit_handler(struct work_struct *work)

	ATRACE_INT("sde_smmu_ctrl", 0);
	ret = sde_smmu_ctrl(1);
	if (IS_ERR_VALUE(ret)) {
	if (ret < 0) {
		SDEROT_ERR("IOMMU attach failed\n");
		goto smmu_error;
	}
+18 −23
Original line number Diff line number Diff line
@@ -249,25 +249,21 @@ static int sde_rotator_validate_item(struct sde_rotator_ctx *ctx,
/*
 * sde_rotator_queue_setup - vb2_ops queue_setup callback.
 * @q: Pointer to vb2 queue struct.
 * @parg: Pointer to v4l2 format struct (NULL is valid argument).
 * @num_buffers: Pointer of number of buffers requested.
 * @num_planes: Pointer to number of planes requested.
 * @sizes: Array containing sizes of planes.
 * @alloc_ctxs: Array of allocated contexts for each plane.
 */
static int sde_rotator_queue_setup(struct vb2_queue *q,
	const void *parg,
	unsigned int *num_buffers, unsigned int *num_planes,
	unsigned int sizes[], void *alloc_ctxs[])
	unsigned int sizes[], struct device *alloc_devs[])
{
	struct sde_rotator_ctx *ctx = vb2_get_drv_priv(q);
	const struct v4l2_format *fmt = parg;
	int i;

	if (!num_buffers)
		return -EINVAL;

	if (fmt == NULL) {
	switch (q->type) {
	case V4L2_BUF_TYPE_VIDEO_OUTPUT:
		sizes[0] = ctx->format_out.fmt.pix.sizeimage;
@@ -278,12 +274,9 @@ static int sde_rotator_queue_setup(struct vb2_queue *q,
	default:
		return -EINVAL;
	}
	} else {
		sizes[0] = fmt->fmt.pix.sizeimage;
	}

	*num_planes = 1;
	alloc_ctxs[0] = ctx;
	alloc_devs[0] = (struct device *)ctx;

	switch (q->type) {
	case V4L2_BUF_TYPE_VIDEO_OUTPUT:
@@ -500,7 +493,7 @@ static void sde_rotator_stop_streaming(struct vb2_queue *q)
}

/* Videobuf2 queue callbacks. */
static struct vb2_ops sde_rotator_vb2_q_ops = {
static const struct vb2_ops sde_rotator_vb2_q_ops = {
	.queue_setup     = sde_rotator_queue_setup,
	.buf_queue       = sde_rotator_buf_queue,
	.start_streaming = sde_rotator_start_streaming,
@@ -512,16 +505,16 @@ static struct vb2_ops sde_rotator_vb2_q_ops = {

/*
 * sde_rotator_get_userptr - Map and get buffer handler for user pointer buffer.
 * @alloc_ctx: Contexts allocated in buf_setup.
 * @dev: device allocated in buf_setup.
 * @vaddr: Virtual addr passed from userpsace (in our case ion fd)
 * @size: Size of the buffer
 * @dma_dir: DMA data direction of the given buffer.
 */
static void *sde_rotator_get_userptr(void *alloc_ctx,
static void *sde_rotator_get_userptr(struct device *dev,
	unsigned long vaddr, unsigned long size,
	enum dma_data_direction dma_dir)
{
	struct sde_rotator_ctx *ctx = alloc_ctx;
	struct sde_rotator_ctx *ctx = (struct sde_rotator_ctx *)dev;
	struct sde_rotator_device *rot_dev = ctx->rot_dev;
	struct sde_rotator_buf_handle *buf;
	struct ion_client *iclient = rot_dev->mdata->iclient;
@@ -535,7 +528,7 @@ static void *sde_rotator_get_userptr(void *alloc_ctx,
	buf->ctx = ctx;
	buf->rot_dev = rot_dev;
	if (ctx->secure_camera) {
		buf->handle = ion_import_dma_buf(iclient,
		buf->handle = ion_import_dma_buf_fd(iclient,
				buf->fd);
		if (IS_ERR_OR_NULL(buf->handle)) {
			SDEDEV_ERR(rot_dev->dev,
@@ -824,6 +817,7 @@ static int sde_rotator_queue_init(void *priv, struct vb2_queue *src_vq,
	src_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
	src_vq->lock = &ctx->rot_dev->lock;
	src_vq->min_buffers_needed = 1;
	src_vq->dev = ctx->rot_dev->dev;

	ret = vb2_queue_init(src_vq);
	if (ret) {
@@ -841,6 +835,7 @@ static int sde_rotator_queue_init(void *priv, struct vb2_queue *src_vq,
	dst_vq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_COPY;
	dst_vq->lock = &ctx->rot_dev->lock;
	dst_vq->min_buffers_needed = 1;
	src_vq->dev = ctx->rot_dev->dev;

	ret = vb2_queue_init(dst_vq);
	if (ret) {
+1 −2
Original line number Diff line number Diff line
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -17,7 +17,6 @@
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/sync.h>
#include <linux/delay.h>
#include <linux/debugfs.h>
#include <linux/interrupt.h>
+1 −1
Original line number Diff line number Diff line
@@ -463,7 +463,7 @@ static int sde_mdp_writeback_display(struct sde_mdp_ctl *ctl, void *arg)
	if (ctl->irq_num >= 0)
		enable_irq(ctl->irq_num);
	ret = sde_smmu_ctrl(1);
	if (IS_ERR_VALUE(ret)) {
	if (ret < 0) {
		SDEROT_ERR("IOMMU attach failed\n");
		return ret;
	}
+7 −11
Original line number Diff line number Diff line
@@ -17,14 +17,14 @@
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/file.h>
#include <linux/sync.h>
#include <linux/delay.h>
#include <linux/debugfs.h>
#include <linux/interrupt.h>
#include <linux/dma-mapping.h>
#include <linux/dma-buf.h>
#include <linux/msm_ion.h>
#include <linux/clk/msm-clk.h>
#include <linux/clk.h>
#include <linux/clk/qcom.h>

#include "sde_rotator_core.h"
#include "sde_rotator_util.h"
@@ -420,8 +420,7 @@ static void sde_hw_rotator_map_vaddr(struct sde_dbg_buf *dbgbuf,
	dbgbuf->height = buf->height;

	if (dbgbuf->dmabuf && (dbgbuf->buflen > 0)) {
		dma_buf_begin_cpu_access(dbgbuf->dmabuf, 0, dbgbuf->buflen,
				DMA_FROM_DEVICE);
		dma_buf_begin_cpu_access(dbgbuf->dmabuf, DMA_FROM_DEVICE);
		dbgbuf->vaddr = dma_buf_kmap(dbgbuf->dmabuf, 0);
		SDEROT_DBG("vaddr mapping: 0x%p/%ld w:%d/h:%d\n",
				dbgbuf->vaddr, dbgbuf->buflen,
@@ -437,8 +436,7 @@ static void sde_hw_rotator_unmap_vaddr(struct sde_dbg_buf *dbgbuf)
{
	if (dbgbuf->vaddr) {
		dma_buf_kunmap(dbgbuf->dmabuf, 0, dbgbuf->vaddr);
		dma_buf_end_cpu_access(dbgbuf->dmabuf, 0, dbgbuf->buflen,
				DMA_FROM_DEVICE);
		dma_buf_end_cpu_access(dbgbuf->dmabuf, DMA_FROM_DEVICE);
	}

	dbgbuf->vaddr  = NULL;
@@ -1251,13 +1249,12 @@ static int sde_hw_rotator_swts_create(struct sde_hw_rotator *rot)
	rc = sde_smmu_map_dma_buf(data->srcp_dma_buf, data->srcp_table,
			SDE_IOMMU_DOMAIN_ROT_UNSECURE, &data->addr,
			&data->len, DMA_BIDIRECTIONAL);
	if (IS_ERR_VALUE(rc)) {
	if (rc < 0) {
		SDEROT_ERR("smmu_map_dma_buf failed: (%d)\n", rc);
		goto err_unmap;
	}

	dma_buf_begin_cpu_access(data->srcp_dma_buf, 0, data->len,
			DMA_FROM_DEVICE);
	dma_buf_begin_cpu_access(data->srcp_dma_buf, DMA_FROM_DEVICE);
	rot->swts_buffer = dma_buf_kmap(data->srcp_dma_buf, 0);
	if (IS_ERR_OR_NULL(rot->swts_buffer)) {
		SDEROT_ERR("ion kernel memory mapping failed\n");
@@ -1301,8 +1298,7 @@ static void sde_hw_rotator_swtc_destroy(struct sde_hw_rotator *rot)

	data = &rot->swts_buf;

	dma_buf_end_cpu_access(data->srcp_dma_buf, 0, data->len,
			DMA_FROM_DEVICE);
	dma_buf_end_cpu_access(data->srcp_dma_buf, DMA_FROM_DEVICE);
	dma_buf_kunmap(data->srcp_dma_buf, 0, rot->swts_buffer);

	sde_smmu_unmap_dma_buf(data->srcp_table, SDE_IOMMU_DOMAIN_ROT_UNSECURE,
Loading