1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #ifndef VC_VCHI_BUFMAN_H |
29 | #define VC_VCHI_BUFMAN_H |
30 | |
31 | #include "interface/vctypes/vc_image_types.h" |
32 | #include "interface/vchi/vchi.h" |
33 | #ifdef __SYMBIAN32__ |
34 | #include "interface/vmcs_host/vc_vchi_bufman_defs.h" |
35 | typedef uint32_t DISPMANX_RESOURCE_HANDLE_T; |
36 | namespace BufManX { |
37 | #else |
38 | #include "interface/vmcs_host/vc_dispmanx.h" |
39 | #include "interface/vmcs_host/vc_vchi_bufman_defs.h" |
40 | #endif |
41 | |
42 | typedef void (*vc_bufman_callback_t) (void *next_cookie, void *next_cookie2, int32_t success); |
43 | |
44 | VCHPRE_ void VCHPOST_ vc_vchi_bufman_init(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections); |
45 | |
46 | typedef struct |
47 | { |
48 | buf_frame_type_t type; |
49 | int width, height, pitch; |
50 | int bpp; // bits per pixel |
51 | int size; |
52 | void *pixels; |
53 | } BUFMANX_IMAGE_T; |
54 | |
55 | #define BUFMAN_TRANSFORM_HFLIP (1<<0) |
56 | #define BUFMAN_TRANSFORM_VFLIP (1<<1) |
57 | #define BUFMAN_TRANSFORM_TRANSPOSE (1<<2) |
58 | |
59 | typedef enum { |
60 | BUFMAN_TRANSFORM_ROT0 = 0, |
61 | BUFMAN_TRANSFORM_MIRROR_ROT0 = BUFMAN_TRANSFORM_HFLIP, |
62 | BUFMAN_TRANSFORM_MIRROR_ROT180 = BUFMAN_TRANSFORM_VFLIP, |
63 | BUFMAN_TRANSFORM_ROT180 = BUFMAN_TRANSFORM_HFLIP|BUFMAN_TRANSFORM_VFLIP, |
64 | BUFMAN_TRANSFORM_MIRROR_ROT90 = BUFMAN_TRANSFORM_TRANSPOSE, |
65 | BUFMAN_TRANSFORM_ROT270 = BUFMAN_TRANSFORM_TRANSPOSE|BUFMAN_TRANSFORM_HFLIP, |
66 | BUFMAN_TRANSFORM_ROT90 = BUFMAN_TRANSFORM_TRANSPOSE|BUFMAN_TRANSFORM_VFLIP, |
67 | BUFMAN_TRANSFORM_MIRROR_ROT270 = BUFMAN_TRANSFORM_TRANSPOSE|BUFMAN_TRANSFORM_HFLIP|BUFMAN_TRANSFORM_VFLIP, |
68 | } BUFMAN_TRANSFORM_T; |
69 | |
70 | |
71 | // we use an opaque type here as the internals shouldn't be used externally, but allocation of the size of the block is required by the caller. |
72 | #define BUFMANX_HANDLE_T_SIZE 1024 |
73 | typedef struct { |
74 | char opaque[BUFMANX_HANDLE_T_SIZE]; |
75 | } BUFMANX_HANDLE_T; |
76 | |
77 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_convert_init(void); |
78 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_set_transform_buffer(void *pixels, int size); |
79 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_allocate_image(BUFMANX_IMAGE_T *image); |
80 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_release_image(BUFMANX_IMAGE_T *image); |
81 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_get_default_pitch( BUFMANX_IMAGE_T *src ); |
82 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_get_default_size(BUFMANX_IMAGE_T *src); |
83 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_push ( BUFMANX_HANDLE_T *h, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 ); |
84 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_pull ( BUFMANX_HANDLE_T *h, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 ); |
85 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_pull_blocking ( BUFMANX_HANDLE_T *h, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform ); |
86 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_push_blocking ( BUFMANX_HANDLE_T *h, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform ); |
87 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_pull_striped ( BUFMANX_HANDLE_T *xh, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 ); |
88 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_pull_striped_blocking ( BUFMANX_HANDLE_T *xh, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform ); |
89 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_push_striped ( BUFMANX_HANDLE_T *xh, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 ); |
90 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_push_striped_blocking ( BUFMANX_HANDLE_T *xh, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, const VC_RECT_T *src_rect, const VC_RECT_T *dest_rect, BUFMAN_TRANSFORM_T transform ); |
91 | |
92 | VCHPRE_ void VCHPOST_ vc_bufmanx_push_multi ( BUFMANX_HANDLE_T *h, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 ); |
93 | VCHPRE_ void VCHPOST_ vc_bufmanx_pull_multi ( BUFMANX_HANDLE_T *h, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 ); |
94 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_push_multi_blocking ( BUFMANX_HANDLE_T *h, const BUFMANX_IMAGE_T *src, DISPMANX_RESOURCE_HANDLE_T dst, BUFMAN_TRANSFORM_T transform ); |
95 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_pull_multi_blocking ( BUFMANX_HANDLE_T *h, BUFMANX_IMAGE_T *dst, const DISPMANX_RESOURCE_HANDLE_T src, BUFMAN_TRANSFORM_T transform ); |
96 | |
97 | // Allocate the specified number and type of buffers on the server side, for use with streams |
98 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_allocate_buffers |
99 | (uint32_t stream, uint32_t num_of_buffers, |
100 | buf_frame_type_t type, uint32_t width, uint32_t height); |
101 | |
102 | // Free buffers on the server which are associated with the specified stream |
103 | #define VC_BUFMANX_FREE_BUFFERS_ALL 0 |
104 | VCHPRE_ int32_t VCHPOST_ vc_bufmanx_free_buffers(uint32_t stream, uint32_t num_of_buffers); |
105 | |
106 | // Like vc_bufmanx_push_multi(), but specifies a stream, rather than a dispmanx resource handle, |
107 | // to push the data to. |
108 | VCHPRE_ void VCHPOST_ vc_bufmanx_push_multi_stream ( BUFMANX_HANDLE_T *xh, const BUFMANX_IMAGE_T *src, uint32_t stream, BUFMAN_TRANSFORM_T transform, vc_bufman_callback_t callback, void *cookie, void *cookie2 ); |
109 | |
110 | VCHPRE_ VC_IMAGE_TYPE_T VCHPOST_ vc_bufmanx_get_vc_image_type(buf_frame_type_t bm_type); |
111 | |
112 | #ifdef __SYMBIAN32__ |
113 | } // namespace BufManX |
114 | #endif |
115 | |
116 | #endif /* VC_VCHI_BUFMAN_H */ |
117 | |