Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 2 | * |
| 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> |
Laura Abbott | 5b1e6f1 | 2012-05-28 08:13:55 -0700 | [diff] [blame] | 19 | #include <mach/iommu_domains.h> |
Mitchel Humpherys | 252fa6a | 2012-09-06 10:28:47 -0700 | [diff] [blame] | 20 | #include <linux/msm_ion.h> |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 21 | |
| 22 | struct videobuf2_mapping { |
| 23 | unsigned int count; |
| 24 | }; |
| 25 | |
Kiran Kumar H N | 5e08d77 | 2011-10-03 10:19:15 -0700 | [diff] [blame] | 26 | enum videobuf2_buffer_type { |
| 27 | VIDEOBUF2_SINGLE_PLANE, |
| 28 | VIDEOBUF2_MULTIPLE_PLANES |
| 29 | }; |
| 30 | |
| 31 | struct videobuf2_sp_offset { |
| 32 | uint32_t y_off; |
| 33 | uint32_t cbcr_off; |
| 34 | }; |
| 35 | |
| 36 | struct videobuf2_msm_offset { |
| 37 | union { |
| 38 | struct videobuf2_sp_offset sp_off; |
| 39 | uint32_t data_offset; |
| 40 | }; |
| 41 | }; |
| 42 | |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 43 | struct videobuf2_contig_pmem { |
| 44 | u32 magic; |
| 45 | void *vaddr; |
| 46 | int phyaddr; |
| 47 | unsigned long size; |
| 48 | int is_userptr; |
Kiran Kumar H N | 5e08d77 | 2011-10-03 10:19:15 -0700 | [diff] [blame] | 49 | /* Offset of the plane inside the buffer */ |
| 50 | struct videobuf2_msm_offset offset; |
| 51 | enum videobuf2_buffer_type buffer_type; |
| 52 | int path; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 53 | struct file *file; |
Kiran Kumar H N | 5e08d77 | 2011-10-03 10:19:15 -0700 | [diff] [blame] | 54 | /* Offset of the buffer */ |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 55 | uint32_t addr_offset; |
| 56 | int dirty; |
| 57 | unsigned int count; |
| 58 | void *alloc_ctx; |
Kiran Kumar H N | ceea762 | 2011-08-23 14:01:03 -0700 | [diff] [blame] | 59 | unsigned long mapped_phyaddr; |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 60 | struct ion_handle *ion_handle; |
Ankit Premrajka | d814743 | 2012-01-06 09:45:11 -0800 | [diff] [blame] | 61 | struct ion_client *client; |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 62 | }; |
| 63 | void 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); |
| 68 | int videobuf2_pmem_contig_mmap_get(struct videobuf2_contig_pmem *mem, |
Kiran Kumar H N | 5e08d77 | 2011-10-03 10:19:15 -0700 | [diff] [blame] | 69 | struct videobuf2_msm_offset *offset, |
| 70 | enum videobuf2_buffer_type, int path); |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 71 | int videobuf2_pmem_contig_user_get(struct videobuf2_contig_pmem *mem, |
Kiran Kumar H N | 5e08d77 | 2011-10-03 10:19:15 -0700 | [diff] [blame] | 72 | struct videobuf2_msm_offset *offset, |
| 73 | enum videobuf2_buffer_type, |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 74 | uint32_t addr_offset, int path, |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 75 | struct ion_client *client, |
| 76 | int domain_num); |
Ankit Premrajka | 748a70a | 2011-11-01 08:22:04 -0700 | [diff] [blame] | 77 | void videobuf2_pmem_contig_user_put(struct videobuf2_contig_pmem *mem, |
Ankit Premrajka | 79b9f22 | 2012-07-02 12:38:34 -0700 | [diff] [blame] | 78 | struct ion_client *client, int domain_num); |
Ankit Premrajka | c6864b8 | 2011-07-15 11:43:41 -0700 | [diff] [blame] | 79 | unsigned long videobuf2_to_pmem_contig(struct vb2_buffer *buf, |
| 80 | unsigned int plane_no); |
Mingcheng Zhu | 9812bd3 | 2011-07-22 22:57:11 -0700 | [diff] [blame] | 81 | |
| 82 | #endif /* _VIDEOBUF2_PMEM_CONTIG_H */ |