camera_v2:jpeg_10: Multiple porting changes

1. Correct the declaration of jpeg IOCTLs.
2. Resolve compilation errors due to incompatible data types.
3. Move #ifdefs out of function bodies.

Signed-off-by: Kamen Kirov <kkirov@codeaurora.org>
Change-Id: I50cc9ab77934b2d0b6d8ae40ede0cbc617470172
This commit is contained in:
Kamen Kirov 2013-11-25 08:10:48 -08:00
parent b8a2a10e1f
commit 58aaa58034
4 changed files with 77 additions and 51 deletions

View File

@ -393,7 +393,7 @@ void msm_jpeg_io_dump(void *base, int size)
p_str = line_str;
for (i = 0; i < size/4; i++) {
if (i % 4 == 0) {
snprintf(p_str, 12, "%08x: ", (u32) p);
snprintf(p_str, 12, "%08lx: ", (unsigned long)p);
p_str += 10;
}
data = readl_relaxed(p++);

View File

@ -170,6 +170,50 @@ static struct msm_bus_scale_pdata msm_jpeg_bus_client_pdata = {
.name = "msm_jpeg",
};
#ifdef CONFIG_MSM_IOMMU
static int msm_jpeg_attach_iommu(struct msm_jpeg_device *pgmn_dev)
{
int i;
for (i = 0; i < pgmn_dev->iommu_cnt; i++) {
int rc = iommu_attach_device(pgmn_dev->domain,
pgmn_dev->iommu_ctx_arr[i]);
if (rc < 0) {
JPEG_PR_ERR("%s: Device attach failed\n", __func__);
return -ENODEV;
}
JPEG_DBG("%s:%d] dom 0x%lx ctx 0x%lx", __func__, __LINE__,
(unsigned long)pgmn_dev->domain,
(unsigned long)pgmn_dev->iommu_ctx_arr[i]);
}
return 0;
}
static int msm_jpeg_detach_iommu(struct msm_jpeg_device *pgmn_dev)
{
int i;
for (i = 0; i < pgmn_dev->iommu_cnt; i++) {
JPEG_DBG("%s:%d] dom 0x%lx ctx 0x%lx", __func__, __LINE__,
(unsigned long)pgmn_dev->domain,
(unsigned long)pgmn_dev->iommu_ctx_arr[i]);
iommu_detach_device(pgmn_dev->domain,
pgmn_dev->iommu_ctx_arr[i]);
}
return 0;
}
#else
static int msm_jpeg_attach_iommu(struct msm_jpeg_device *pgmn_dev)
{
return 0;
}
static int msm_jpeg_detach_iommu(struct msm_jpeg_device *pgmn_dev)
{
return 0;
}
#endif
int msm_jpeg_platform_init(struct platform_device *pdev,
struct resource **mem,
void **base,
@ -178,7 +222,6 @@ int msm_jpeg_platform_init(struct platform_device *pdev,
void *context)
{
int rc = -1;
int i = 0;
int jpeg_irq;
struct resource *jpeg_mem, *jpeg_io, *jpeg_irq_res;
void *jpeg_base;
@ -255,20 +298,10 @@ int msm_jpeg_platform_init(struct platform_device *pdev,
JPEG_DBG("%s:%d] jpeg_vbif 0x%x", __func__, __LINE__,
(uint32_t)pgmn_dev->jpeg_vbif);
#ifdef CONFIG_MSM_IOMMU
for (i = 0; i < pgmn_dev->iommu_cnt; i++) {
rc = iommu_attach_device(pgmn_dev->domain,
pgmn_dev->iommu_ctx_arr[i]);
if (rc < 0) {
rc = -ENODEV;
JPEG_PR_ERR("%s: Device attach failed\n", __func__);
goto fail_iommu;
}
JPEG_DBG("%s:%d] dom 0x%x ctx 0x%x", __func__, __LINE__,
(uint32_t)pgmn_dev->domain,
(uint32_t)pgmn_dev->iommu_ctx_arr[i]);
}
#endif
rc = msm_jpeg_attach_iommu(pgmn_dev);
if (rc < 0)
goto fail_iommu;
set_vbif_params(pgmn_dev, pgmn_dev->jpeg_vbif);
rc = request_irq(jpeg_irq, handler, IRQF_TRIGGER_RISING, "jpeg",
@ -290,19 +323,12 @@ int msm_jpeg_platform_init(struct platform_device *pdev,
return rc;
fail_request_irq:
#ifdef CONFIG_MSM_IOMMU
for (i = 0; i < pgmn_dev->iommu_cnt; i++) {
JPEG_PR_ERR("%s:%d] dom 0x%x ctx 0x%x", __func__, __LINE__,
(uint32_t)pgmn_dev->domain,
(uint32_t)pgmn_dev->iommu_ctx_arr[i]);
iommu_detach_device(pgmn_dev->domain,
pgmn_dev->iommu_ctx_arr[i]);
}
#endif
msm_jpeg_detach_iommu(pgmn_dev);
fail_iommu:
iounmap(pgmn_dev->jpeg_vbif);
fail_vbif:
msm_cam_clk_enable(&pgmn_dev->pdev->dev, jpeg_8x_clk_info,
pgmn_dev->jpeg_clk, ARRAY_SIZE(jpeg_8x_clk_info), 0);
@ -329,19 +355,13 @@ int msm_jpeg_platform_release(struct resource *mem, void *base, int irq,
void *context)
{
int result = 0;
int i = 0;
struct msm_jpeg_device *pgmn_dev =
(struct msm_jpeg_device *) context;
free_irq(irq, context);
#ifdef CONFIG_MSM_IOMMU
for (i = 0; i < pgmn_dev->iommu_cnt; i++) {
iommu_detach_device(pgmn_dev->domain,
pgmn_dev->iommu_ctx_arr[i]);
JPEG_DBG("%s:%d]", __func__, __LINE__);
}
#endif
msm_jpeg_detach_iommu(pgmn_dev);
msm_bus_scale_unregister_client(pgmn_dev->jpeg_bus_client);
msm_cam_clk_enable(&pgmn_dev->pdev->dev, jpeg_8x_clk_info,

View File

@ -105,7 +105,7 @@ inline int msm_jpeg_q_in_buf(struct msm_jpeg_q *q_p,
inline int msm_jpeg_q_wait(struct msm_jpeg_q *q_p)
{
int tm = MAX_SCHEDULE_TIMEOUT; /* 500ms */
long tm = MAX_SCHEDULE_TIMEOUT; /* 500ms */
int rc;
JPEG_DBG("%s:%d] %s wait\n", __func__, __LINE__, q_p->name);
@ -805,7 +805,7 @@ int msm_jpeg_ioctl_test_dump_region(struct msm_jpeg_device *pgmn_dev,
}
int msm_jpeg_ioctl_set_clk_rate(struct msm_jpeg_device *pgmn_dev,
unsigned long arg)
void * __user arg)
{
long clk_rate;
int rc;
@ -815,7 +815,7 @@ int msm_jpeg_ioctl_set_clk_rate(struct msm_jpeg_device *pgmn_dev,
JPEG_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
return -EFAULT;
}
if (get_user(clk_rate, (long __user *)arg)) {
if (get_user(clk_rate, (unsigned int __user *)arg)) {
JPEG_PR_ERR("%s:%d] failed\n", __func__, __LINE__);
return -EFAULT;
}
@ -904,7 +904,7 @@ long __msm_jpeg_ioctl(struct msm_jpeg_device *pgmn_dev,
break;
case MSM_JPEG_IOCTL_SET_CLK_RATE:
rc = msm_jpeg_ioctl_set_clk_rate(pgmn_dev, arg);
rc = msm_jpeg_ioctl_set_clk_rate(pgmn_dev, (void __user *) arg);
break;
default:
JPEG_PR_ERR(KERN_INFO "%s:%d] cmd = %d not supported\n",
@ -914,7 +914,7 @@ long __msm_jpeg_ioctl(struct msm_jpeg_device *pgmn_dev,
}
return rc;
}
#ifdef CONFIG_MSM_IOMMU
static int camera_register_domain(void)
{
struct msm_iova_partition camera_fw_partition = {
@ -930,13 +930,17 @@ static int camera_register_domain(void)
};
return msm_register_domain(&camera_fw_layout);
}
#endif
int __msm_jpeg_init(struct msm_jpeg_device *pgmn_dev)
{
int rc = 0, i = 0, j = 0;
int rc = 0;
int idx = 0;
#ifdef CONFIG_MSM_IOMMU
int i = 0, j = 0;
char *iommu_name[JPEG_DEV_CNT] = {"jpeg_enc0", "jpeg_enc1",
"jpeg_dec"};
#endif
mutex_init(&pgmn_dev->lock);
@ -985,7 +989,9 @@ int __msm_jpeg_init(struct msm_jpeg_device *pgmn_dev)
#endif
return rc;
#ifdef CONFIG_MSM_IOMMU
error:
#endif
mutex_destroy(&pgmn_dev->lock);
return -EFAULT;
}

View File

@ -11,52 +11,52 @@
#define MSM_JPEG_IOCTL_MAGIC 'g'
#define MSM_JPEG_IOCTL_GET_HW_VERSION \
_IOW(MSM_JPEG_IOCTL_MAGIC, 1, struct msm_jpeg_hw_cmd *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 1, struct msm_jpeg_hw_cmd)
#define MSM_JPEG_IOCTL_RESET \
_IOW(MSM_JPEG_IOCTL_MAGIC, 2, struct msm_jpeg_ctrl_cmd *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 2, struct msm_jpeg_ctrl_cmd)
#define MSM_JPEG_IOCTL_STOP \
_IOW(MSM_JPEG_IOCTL_MAGIC, 3, struct msm_jpeg_hw_cmds *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 3, struct msm_jpeg_hw_cmds)
#define MSM_JPEG_IOCTL_START \
_IOW(MSM_JPEG_IOCTL_MAGIC, 4, struct msm_jpeg_hw_cmds *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 4, struct msm_jpeg_hw_cmds)
#define MSM_JPEG_IOCTL_INPUT_BUF_ENQUEUE \
_IOW(MSM_JPEG_IOCTL_MAGIC, 5, struct msm_jpeg_buf *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 5, struct msm_jpeg_buf)
#define MSM_JPEG_IOCTL_INPUT_GET \
_IOW(MSM_JPEG_IOCTL_MAGIC, 6, struct msm_jpeg_buf *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 6, struct msm_jpeg_buf)
#define MSM_JPEG_IOCTL_INPUT_GET_UNBLOCK \
_IOW(MSM_JPEG_IOCTL_MAGIC, 7, int)
#define MSM_JPEG_IOCTL_OUTPUT_BUF_ENQUEUE \
_IOW(MSM_JPEG_IOCTL_MAGIC, 8, struct msm_jpeg_buf *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 8, struct msm_jpeg_buf)
#define MSM_JPEG_IOCTL_OUTPUT_GET \
_IOW(MSM_JPEG_IOCTL_MAGIC, 9, struct msm_jpeg_buf *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 9, struct msm_jpeg_buf)
#define MSM_JPEG_IOCTL_OUTPUT_GET_UNBLOCK \
_IOW(MSM_JPEG_IOCTL_MAGIC, 10, int)
#define MSM_JPEG_IOCTL_EVT_GET \
_IOW(MSM_JPEG_IOCTL_MAGIC, 11, struct msm_jpeg_ctrl_cmd *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 11, struct msm_jpeg_ctrl_cmd)
#define MSM_JPEG_IOCTL_EVT_GET_UNBLOCK \
_IOW(MSM_JPEG_IOCTL_MAGIC, 12, int)
#define MSM_JPEG_IOCTL_HW_CMD \
_IOW(MSM_JPEG_IOCTL_MAGIC, 13, struct msm_jpeg_hw_cmd *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 13, struct msm_jpeg_hw_cmd)
#define MSM_JPEG_IOCTL_HW_CMDS \
_IOW(MSM_JPEG_IOCTL_MAGIC, 14, struct msm_jpeg_hw_cmds *)
_IOW(MSM_JPEG_IOCTL_MAGIC, 14, struct msm_jpeg_hw_cmds)
#define MSM_JPEG_IOCTL_TEST_DUMP_REGION \
_IOW(MSM_JPEG_IOCTL_MAGIC, 15, unsigned long)
#define MSM_JPEG_IOCTL_SET_CLK_RATE \
_IOW(MSM_JPEG_IOCTL_MAGIC, 16, unsigned long)
_IOW(MSM_JPEG_IOCTL_MAGIC, 16, unsigned int)
#define MSM_JPEG_MODE_REALTIME_ENCODE 0
#define MSM_JPEG_MODE_OFFLINE_ENCODE 1