tu: Implement fallback linear staging blit for CopyImage
[mesa.git] / src / gallium / state_trackers / omx / tizonia / h264dinport.c
1 /**************************************************************************
2 *
3 * Copyright 2013 Advanced Micro Devices, Inc.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #include <assert.h>
29 #include <string.h>
30 #include <limits.h>
31
32 #include <tizplatform.h>
33 #include <tizkernel.h>
34
35 #include "vl/vl_winsys.h"
36
37 #include "h264d.h"
38 #include "h264dinport.h"
39 #include "h264dinport_decls.h"
40 #include "vid_dec_common.h"
41
42 /*
43 * h264dinport class
44 */
45
46 static void * h264d_inport_ctor(void * ap_obj, va_list * app)
47 {
48 return super_ctor(typeOf(ap_obj, "h264dinport"), ap_obj, app);
49 }
50
51 static void * h264d_inport_dtor(void * ap_obj)
52 {
53 return super_dtor(typeOf(ap_obj, "h264dinport"), ap_obj);
54 }
55
56 /*
57 * from tiz_api
58 */
59
60 static OMX_ERRORTYPE h264d_inport_SetParameter(const void * ap_obj, OMX_HANDLETYPE ap_hdl,
61 OMX_INDEXTYPE a_index, OMX_PTR ap_struct)
62 {
63 OMX_ERRORTYPE err = OMX_ErrorNone;
64
65 assert(ap_obj);
66 assert(ap_hdl);
67 assert(ap_struct);
68
69 if (a_index == OMX_IndexParamPortDefinition) {
70 vid_dec_PrivateType * p_prc = tiz_get_prc(ap_hdl);
71 OMX_VIDEO_PORTDEFINITIONTYPE * p_def = &(p_prc->out_port_def_.format.video);
72 OMX_PARAM_PORTDEFINITIONTYPE * i_def = (OMX_PARAM_PORTDEFINITIONTYPE *) ap_struct;
73
74 /* Make changes only if there is a resolution change */
75 if ((p_def->nFrameWidth == i_def->format.video.nFrameWidth) &&
76 (p_def->nFrameHeight == i_def->format.video.nFrameHeight) &&
77 (p_def->eCompressionFormat == i_def->format.video.eCompressionFormat))
78 return err;
79
80 /* Set some default values if not set */
81 if (i_def->format.video.nStride == 0)
82 i_def->format.video.nStride = i_def->format.video.nFrameWidth;
83 if (i_def->format.video.nSliceHeight == 0)
84 i_def->format.video.nSliceHeight = i_def->format.video.nFrameHeight;
85
86 err = super_SetParameter(typeOf (ap_obj, "h264dinport"), ap_obj,
87 ap_hdl, a_index, ap_struct);
88 if (err == OMX_ErrorNone) {
89 tiz_port_t * p_obj = (tiz_port_t *) ap_obj;
90
91 /* Set desired buffer size that will be used when allocating input buffers */
92 p_obj->portdef_.nBufferSize = i_def->format.video.nFrameWidth * i_def->format.video.nFrameHeight * 512 / (16*16);
93
94 /* Get a locally copy of port def. Useful for the early return above */
95 tiz_check_omx(tiz_api_GetParameter(tiz_get_krn(handleOf(p_prc)), handleOf(p_prc),
96 OMX_IndexParamPortDefinition, &(p_prc->out_port_def_)));
97 }
98 }
99
100 return err;
101 }
102
103 /*
104 * h264dinport_class
105 */
106
107 static void * h264d_inport_class_ctor(void * ap_obj, va_list * app)
108 {
109 /* NOTE: Class methods might be added in the future. None for now. */
110 return super_ctor (typeOf (ap_obj, "h264dinport_class"), ap_obj, app);
111 }
112
113 /*
114 * initialization
115 */
116
117 void * h264d_inport_class_init(void * ap_tos, void * ap_hdl)
118 {
119 void * tizavcport = tiz_get_type(ap_hdl, "tizavcport");
120 void * h264dinport_class
121 = factory_new(classOf(tizavcport), "h264dinport_class",
122 classOf(tizavcport), sizeof(h264d_inport_class_t),
123 ap_tos, ap_hdl, ctor, h264d_inport_class_ctor, 0);
124 return h264dinport_class;
125 }
126
127 void * h264d_inport_init(void * ap_tos, void * ap_hdl)
128 {
129 void * tizavcport = tiz_get_type (ap_hdl, "tizavcport");
130 void * h264dinport_class = tiz_get_type (ap_hdl, "h264dinport_class");
131 void * h264dinport = factory_new
132 /* TIZ_CLASS_COMMENT: class type, class name, parent, size */
133 (h264dinport_class, "h264dinport", tizavcport,
134 sizeof (h264d_inport_t),
135 /* TIZ_CLASS_COMMENT: class constructor */
136 ap_tos, ap_hdl,
137 /* TIZ_CLASS_COMMENT: class constructor */
138 ctor, h264d_inport_ctor,
139 /* TIZ_CLASS_COMMENT: class destructor */
140 dtor, h264d_inport_dtor,
141 /* TIZ_CLASS_COMMENT: */
142 tiz_api_SetParameter, h264d_inport_SetParameter,
143 /* TIZ_CLASS_COMMENT: stop value*/
144 0);
145
146 return h264dinport;
147 }