blob: d23a0f608b486cc639c7d87258880b5905ef8d13 [file] [log] [blame]
Flemmard17726d02013-05-20 14:27:16 -07001/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
Mingcheng Zhu9812bd32011-07-22 22:57:11 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * helper functions for physically contiguous PMEM capture buffers
13 */
14
15#ifndef _VIDEOBUF2_PMEM_CONTIG_H
16#define _VIDEOBUF2_PMEM_CONTIG_H
17
18#include <media/videobuf2-core.h>
Flemmard17726d02013-05-20 14:27:16 -070019#include <mach/msm_subsystem_map.h>
Flemmard64bfe1e2013-05-20 14:53:27 -070020#include <linux/msm_ion.h>
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070021
22struct videobuf2_mapping {
23 unsigned int count;
24};
25
Kiran Kumar H N5e08d772011-10-03 10:19:15 -070026enum videobuf2_buffer_type {
27 VIDEOBUF2_SINGLE_PLANE,
28 VIDEOBUF2_MULTIPLE_PLANES
29};
30
31struct videobuf2_sp_offset {
32 uint32_t y_off;
33 uint32_t cbcr_off;
34};
35
36struct videobuf2_msm_offset {
37 union {
38 struct videobuf2_sp_offset sp_off;
39 uint32_t data_offset;
40 };
41};
42
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070043struct videobuf2_contig_pmem {
44 u32 magic;
45 void *vaddr;
46 int phyaddr;
47 unsigned long size;
48 int is_userptr;
Flemmard17726d02013-05-20 14:27:16 -070049
Kiran Kumar H N5e08d772011-10-03 10:19:15 -070050 struct videobuf2_msm_offset offset;
51 enum videobuf2_buffer_type buffer_type;
52 int path;
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070053 struct file *file;
Flemmard17726d02013-05-20 14:27:16 -070054
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070055 uint32_t addr_offset;
56 int dirty;
57 unsigned int count;
58 void *alloc_ctx;
Kiran Kumar H Nceea7622011-08-23 14:01:03 -070059 unsigned long mapped_phyaddr;
Ankit Premrajka748a70a2011-11-01 08:22:04 -070060 struct ion_handle *ion_handle;
Ankit Premrajkad8147432012-01-06 09:45:11 -080061 struct ion_client *client;
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070062};
63void videobuf2_queue_pmem_contig_init(struct vb2_queue *q,
64 enum v4l2_buf_type type,
65 const struct vb2_ops *ops,
66 unsigned int size,
67 void *priv);
68int videobuf2_pmem_contig_mmap_get(struct videobuf2_contig_pmem *mem,
Kiran Kumar H N5e08d772011-10-03 10:19:15 -070069 struct videobuf2_msm_offset *offset,
70 enum videobuf2_buffer_type, int path);
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070071int videobuf2_pmem_contig_user_get(struct videobuf2_contig_pmem *mem,
Kiran Kumar H N5e08d772011-10-03 10:19:15 -070072 struct videobuf2_msm_offset *offset,
73 enum videobuf2_buffer_type,
Ankit Premrajka748a70a2011-11-01 08:22:04 -070074 uint32_t addr_offset, int path,
Flemmard17726d02013-05-20 14:27:16 -070075 struct ion_client *client);
Ankit Premrajka748a70a2011-11-01 08:22:04 -070076void videobuf2_pmem_contig_user_put(struct videobuf2_contig_pmem *mem,
Flemmard17726d02013-05-20 14:27:16 -070077 struct ion_client *client);
Ankit Premrajkac6864b82011-07-15 11:43:41 -070078unsigned long videobuf2_to_pmem_contig(struct vb2_buffer *buf,
79 unsigned int plane_no);
Mingcheng Zhu9812bd32011-07-22 22:57:11 -070080
Flemmard17726d02013-05-20 14:27:16 -070081#endif