2 * Copyright © 2010 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sub license, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial portions
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19 * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * Xiang Haihao <haihao.xiang@intel.com>
34 #include "intel_batchbuffer.h"
35 #include "intel_driver.h"
36 #include "i965_defines.h"
37 #include "i965_structs.h"
38 #include "i965_drv_video.h"
39 #include "i965_post_processing.h"
40 #include "i965_render.h"
42 #define HAS_PP(ctx) (IS_IRONLAKE((ctx)->intel.device_id) || \
43 IS_GEN6((ctx)->intel.device_id) || \
44 IS_GEN7((ctx)->intel.device_id))
46 #define SURFACE_STATE_PADDED_SIZE_0_I965 ALIGN(sizeof(struct i965_surface_state), 32)
47 #define SURFACE_STATE_PADDED_SIZE_1_I965 ALIGN(sizeof(struct i965_surface_state2), 32)
48 #define SURFACE_STATE_PADDED_SIZE_I965 MAX(SURFACE_STATE_PADDED_SIZE_0_I965, SURFACE_STATE_PADDED_SIZE_1_I965)
50 #define SURFACE_STATE_PADDED_SIZE_0_GEN7 ALIGN(sizeof(struct gen7_surface_state), 32)
51 #define SURFACE_STATE_PADDED_SIZE_1_GEN7 ALIGN(sizeof(struct gen7_surface_state2), 32)
52 #define SURFACE_STATE_PADDED_SIZE_GEN7 MAX(SURFACE_STATE_PADDED_SIZE_0_GEN7, SURFACE_STATE_PADDED_SIZE_1_GEN7)
54 #define SURFACE_STATE_PADDED_SIZE MAX(SURFACE_STATE_PADDED_SIZE_I965, SURFACE_STATE_PADDED_SIZE_GEN7)
55 #define SURFACE_STATE_OFFSET(index) (SURFACE_STATE_PADDED_SIZE * index)
56 #define BINDING_TABLE_OFFSET SURFACE_STATE_OFFSET(MAX_PP_SURFACES)
58 static const uint32_t pp_null_gen5[][4] = {
59 #include "shaders/post_processing/gen5_6/null.g4b.gen5"
62 static const uint32_t pp_nv12_load_save_nv12_gen5[][4] = {
63 #include "shaders/post_processing/gen5_6/nv12_load_save_nv12.g4b.gen5"
66 static const uint32_t pp_nv12_load_save_pl3_gen5[][4] = {
67 #include "shaders/post_processing/gen5_6/nv12_load_save_pl3.g4b.gen5"
70 static const uint32_t pp_pl3_load_save_nv12_gen5[][4] = {
71 #include "shaders/post_processing/gen5_6/pl3_load_save_nv12.g4b.gen5"
74 static const uint32_t pp_pl3_load_save_pl3_gen5[][4] = {
75 #include "shaders/post_processing/gen5_6/pl3_load_save_pl3.g4b.gen5"
78 static const uint32_t pp_nv12_scaling_gen5[][4] = {
79 #include "shaders/post_processing/gen5_6/nv12_scaling_nv12.g4b.gen5"
82 static const uint32_t pp_nv12_avs_gen5[][4] = {
83 #include "shaders/post_processing/gen5_6/nv12_avs_nv12.g4b.gen5"
86 static const uint32_t pp_nv12_dndi_gen5[][4] = {
87 #include "shaders/post_processing/gen5_6/nv12_dndi_nv12.g4b.gen5"
90 static const uint32_t pp_nv12_dn_gen5[][4] = {
91 #include "shaders/post_processing/gen5_6/nv12_dn_nv12.g4b.gen5"
94 static const uint32_t pp_nv12_load_save_pa_gen5[][4] = {
95 #include "shaders/post_processing/gen5_6/nv12_load_save_pa.g4b.gen5"
98 static const uint32_t pp_pl3_load_save_pa_gen5[][4] = {
99 #include "shaders/post_processing/gen5_6/pl3_load_save_pa.g4b.gen5"
102 static const uint32_t pp_pa_load_save_nv12_gen5[][4] = {
103 #include "shaders/post_processing/gen5_6/pa_load_save_nv12.g4b.gen5"
106 static VAStatus pp_null_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
107 const struct i965_surface *src_surface,
108 const VARectangle *src_rect,
109 struct i965_surface *dst_surface,
110 const VARectangle *dst_rect,
112 static VAStatus pp_nv12_avs_initialize_nlas(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
113 const struct i965_surface *src_surface,
114 const VARectangle *src_rect,
115 struct i965_surface *dst_surface,
116 const VARectangle *dst_rect,
118 static VAStatus pp_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
119 const struct i965_surface *src_surface,
120 const VARectangle *src_rect,
121 struct i965_surface *dst_surface,
122 const VARectangle *dst_rect,
124 static VAStatus gen6_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
125 const struct i965_surface *src_surface,
126 const VARectangle *src_rect,
127 struct i965_surface *dst_surface,
128 const VARectangle *dst_rect,
130 static VAStatus pp_plx_load_save_plx_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
131 const struct i965_surface *src_surface,
132 const VARectangle *src_rect,
133 struct i965_surface *dst_surface,
134 const VARectangle *dst_rect,
136 static VAStatus pp_nv12_dndi_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
137 const struct i965_surface *src_surface,
138 const VARectangle *src_rect,
139 struct i965_surface *dst_surface,
140 const VARectangle *dst_rect,
142 static VAStatus pp_nv12_dn_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
143 const struct i965_surface *src_surface,
144 const VARectangle *src_rect,
145 struct i965_surface *dst_surface,
146 const VARectangle *dst_rect,
149 static struct pp_module pp_modules_gen5[] = {
152 "NULL module (for testing)",
155 sizeof(pp_null_gen5),
165 PP_NV12_LOAD_SAVE_N12,
166 pp_nv12_load_save_nv12_gen5,
167 sizeof(pp_nv12_load_save_nv12_gen5),
171 pp_plx_load_save_plx_initialize,
177 PP_NV12_LOAD_SAVE_PL3,
178 pp_nv12_load_save_pl3_gen5,
179 sizeof(pp_nv12_load_save_pl3_gen5),
183 pp_plx_load_save_plx_initialize,
189 PP_PL3_LOAD_SAVE_N12,
190 pp_pl3_load_save_nv12_gen5,
191 sizeof(pp_pl3_load_save_nv12_gen5),
195 pp_plx_load_save_plx_initialize,
201 PP_PL3_LOAD_SAVE_N12,
202 pp_pl3_load_save_pl3_gen5,
203 sizeof(pp_pl3_load_save_pl3_gen5),
207 pp_plx_load_save_plx_initialize
212 "NV12 Scaling module",
214 pp_nv12_scaling_gen5,
215 sizeof(pp_nv12_scaling_gen5),
219 pp_nv12_scaling_initialize,
227 sizeof(pp_nv12_avs_gen5),
231 pp_nv12_avs_initialize_nlas,
239 sizeof(pp_nv12_dndi_gen5),
243 pp_nv12_dndi_initialize,
251 sizeof(pp_nv12_dn_gen5),
255 pp_nv12_dn_initialize,
261 PP_NV12_LOAD_SAVE_PA,
262 pp_nv12_load_save_pa_gen5,
263 sizeof(pp_nv12_load_save_pa_gen5),
267 pp_plx_load_save_plx_initialize,
274 pp_pl3_load_save_pa_gen5,
275 sizeof(pp_pl3_load_save_pa_gen5),
279 pp_plx_load_save_plx_initialize,
285 PP_PA_LOAD_SAVE_NV12,
286 pp_pa_load_save_nv12_gen5,
287 sizeof(pp_pa_load_save_nv12_gen5),
291 pp_plx_load_save_plx_initialize,
296 static const uint32_t pp_null_gen6[][4] = {
297 #include "shaders/post_processing/gen5_6/null.g6b"
300 static const uint32_t pp_nv12_load_save_nv12_gen6[][4] = {
301 #include "shaders/post_processing/gen5_6/nv12_load_save_nv12.g6b"
304 static const uint32_t pp_nv12_load_save_pl3_gen6[][4] = {
305 #include "shaders/post_processing/gen5_6/nv12_load_save_pl3.g6b"
308 static const uint32_t pp_pl3_load_save_nv12_gen6[][4] = {
309 #include "shaders/post_processing/gen5_6/pl3_load_save_nv12.g6b"
312 static const uint32_t pp_pl3_load_save_pl3_gen6[][4] = {
313 #include "shaders/post_processing/gen5_6/pl3_load_save_pl3.g6b"
316 static const uint32_t pp_nv12_scaling_gen6[][4] = {
317 #include "shaders/post_processing/gen5_6/nv12_avs_nv12.g6b"
320 static const uint32_t pp_nv12_avs_gen6[][4] = {
321 #include "shaders/post_processing/gen5_6/nv12_avs_nv12.g6b"
324 static const uint32_t pp_nv12_dndi_gen6[][4] = {
325 #include "shaders/post_processing/gen5_6/nv12_dndi_nv12.g6b"
328 static const uint32_t pp_nv12_dn_gen6[][4] = {
329 #include "shaders/post_processing/gen5_6/nv12_dn_nv12.g6b"
332 static const uint32_t pp_nv12_load_save_pa_gen6[][4] = {
333 #include "shaders/post_processing/gen5_6/nv12_load_save_pa.g6b"
336 static const uint32_t pp_pl3_load_save_pa_gen6[][4] = {
337 #include "shaders/post_processing/gen5_6/pl3_load_save_pa.g6b"
340 static const uint32_t pp_pa_load_save_nv12_gen6[][4] = {
341 #include "shaders/post_processing/gen5_6/pa_load_save_nv12.g6b"
344 static struct pp_module pp_modules_gen6[] = {
347 "NULL module (for testing)",
350 sizeof(pp_null_gen6),
360 PP_NV12_LOAD_SAVE_N12,
361 pp_nv12_load_save_nv12_gen6,
362 sizeof(pp_nv12_load_save_nv12_gen6),
366 pp_plx_load_save_plx_initialize,
372 PP_NV12_LOAD_SAVE_PL3,
373 pp_nv12_load_save_pl3_gen6,
374 sizeof(pp_nv12_load_save_pl3_gen6),
378 pp_plx_load_save_plx_initialize,
384 PP_PL3_LOAD_SAVE_N12,
385 pp_pl3_load_save_nv12_gen6,
386 sizeof(pp_pl3_load_save_nv12_gen6),
390 pp_plx_load_save_plx_initialize,
396 PP_PL3_LOAD_SAVE_N12,
397 pp_pl3_load_save_pl3_gen6,
398 sizeof(pp_pl3_load_save_pl3_gen6),
402 pp_plx_load_save_plx_initialize,
407 "NV12 Scaling module",
409 pp_nv12_scaling_gen6,
410 sizeof(pp_nv12_scaling_gen6),
414 gen6_nv12_scaling_initialize,
422 sizeof(pp_nv12_avs_gen6),
426 pp_nv12_avs_initialize_nlas,
434 sizeof(pp_nv12_dndi_gen6),
438 pp_nv12_dndi_initialize,
446 sizeof(pp_nv12_dn_gen6),
450 pp_nv12_dn_initialize,
455 PP_NV12_LOAD_SAVE_PA,
456 pp_nv12_load_save_pa_gen6,
457 sizeof(pp_nv12_load_save_pa_gen6),
461 pp_plx_load_save_plx_initialize,
468 pp_pl3_load_save_pa_gen6,
469 sizeof(pp_pl3_load_save_pa_gen6),
473 pp_plx_load_save_plx_initialize,
479 PP_PA_LOAD_SAVE_NV12,
480 pp_pa_load_save_nv12_gen6,
481 sizeof(pp_pa_load_save_nv12_gen6),
485 pp_plx_load_save_plx_initialize,
490 static const uint32_t pp_null_gen7[][4] = {
493 static const uint32_t pp_nv12_load_save_nv12_gen7[][4] = {
494 #include "shaders/post_processing/gen7/pl2_to_pl2.g7b"
497 static const uint32_t pp_nv12_load_save_pl3_gen7[][4] = {
498 #include "shaders/post_processing/gen7/pl2_to_pl3.g7b"
501 static const uint32_t pp_pl3_load_save_nv12_gen7[][4] = {
502 #include "shaders/post_processing/gen7/pl3_to_pl2.g7b"
505 static const uint32_t pp_pl3_load_save_pl3_gen7[][4] = {
506 #include "shaders/post_processing/gen7/pl3_to_pl3.g7b"
509 static const uint32_t pp_nv12_scaling_gen7[][4] = {
510 #include "shaders/post_processing/gen7/avs.g7b"
513 static const uint32_t pp_nv12_avs_gen7[][4] = {
514 #include "shaders/post_processing/gen7/avs.g7b"
517 static const uint32_t pp_nv12_dndi_gen7[][4] = {
518 // #include "shaders/post_processing/gen7/dndi.g7b"
521 static const uint32_t pp_nv12_dn_gen7[][4] = {
523 static const uint32_t pp_nv12_load_save_pa_gen7[][4] = {
525 static const uint32_t pp_pl3_load_save_pa_gen7[][4] = {
527 static const uint32_t pp_pa_load_save_nv12_gen7[][4] = {
530 static VAStatus gen7_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
531 const struct i965_surface *src_surface,
532 const VARectangle *src_rect,
533 struct i965_surface *dst_surface,
534 const VARectangle *dst_rect,
536 static VAStatus gen7_pp_nv12_dndi_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
537 const struct i965_surface *src_surface,
538 const VARectangle *src_rect,
539 struct i965_surface *dst_surface,
540 const VARectangle *dst_rect,
542 static VAStatus gen7_pp_nv12_dn_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
543 const struct i965_surface *src_surface,
544 const VARectangle *src_rect,
545 struct i965_surface *dst_surface,
546 const VARectangle *dst_rect,
549 static struct pp_module pp_modules_gen7[] = {
552 "NULL module (for testing)",
555 sizeof(pp_null_gen7),
565 PP_NV12_LOAD_SAVE_N12,
566 pp_nv12_load_save_nv12_gen7,
567 sizeof(pp_nv12_load_save_nv12_gen7),
571 gen7_pp_plx_avs_initialize,
577 PP_NV12_LOAD_SAVE_PL3,
578 pp_nv12_load_save_pl3_gen7,
579 sizeof(pp_nv12_load_save_pl3_gen7),
583 gen7_pp_plx_avs_initialize,
589 PP_PL3_LOAD_SAVE_N12,
590 pp_pl3_load_save_nv12_gen7,
591 sizeof(pp_pl3_load_save_nv12_gen7),
595 gen7_pp_plx_avs_initialize,
601 PP_PL3_LOAD_SAVE_N12,
602 pp_pl3_load_save_pl3_gen7,
603 sizeof(pp_pl3_load_save_pl3_gen7),
607 gen7_pp_plx_avs_initialize,
612 "NV12 Scaling module",
614 pp_nv12_scaling_gen7,
615 sizeof(pp_nv12_scaling_gen7),
619 gen7_pp_plx_avs_initialize,
627 sizeof(pp_nv12_avs_gen7),
631 gen7_pp_plx_avs_initialize,
639 sizeof(pp_nv12_dndi_gen7),
643 gen7_pp_nv12_dndi_initialize,
651 sizeof(pp_nv12_dn_gen7),
655 gen7_pp_nv12_dn_initialize,
660 PP_NV12_LOAD_SAVE_PA,
661 pp_nv12_load_save_pa_gen7,
662 sizeof(pp_nv12_load_save_pa_gen7),
666 pp_plx_load_save_plx_initialize,
673 pp_pl3_load_save_pa_gen7,
674 sizeof(pp_pl3_load_save_pa_gen7),
678 pp_plx_load_save_plx_initialize,
684 PP_PA_LOAD_SAVE_NV12,
685 pp_pa_load_save_nv12_gen7,
686 sizeof(pp_pa_load_save_nv12_gen7),
690 pp_plx_load_save_plx_initialize,
696 pp_get_surface_fourcc(VADriverContextP ctx, const struct i965_surface *surface)
698 struct i965_driver_data *i965 = i965_driver_data(ctx);
701 if (surface->type == I965_SURFACE_TYPE_IMAGE) {
702 struct object_image *obj_image = IMAGE(surface->id);
703 fourcc = obj_image->image.format.fourcc;
705 struct object_surface *obj_surface = SURFACE(surface->id);
706 fourcc = obj_surface->fourcc;
713 pp_set_surface_tiling(struct i965_surface_state *ss, unsigned int tiling)
716 case I915_TILING_NONE:
717 ss->ss3.tiled_surface = 0;
718 ss->ss3.tile_walk = 0;
721 ss->ss3.tiled_surface = 1;
722 ss->ss3.tile_walk = I965_TILEWALK_XMAJOR;
725 ss->ss3.tiled_surface = 1;
726 ss->ss3.tile_walk = I965_TILEWALK_YMAJOR;
732 pp_set_surface2_tiling(struct i965_surface_state2 *ss, unsigned int tiling)
735 case I915_TILING_NONE:
736 ss->ss2.tiled_surface = 0;
737 ss->ss2.tile_walk = 0;
740 ss->ss2.tiled_surface = 1;
741 ss->ss2.tile_walk = I965_TILEWALK_XMAJOR;
744 ss->ss2.tiled_surface = 1;
745 ss->ss2.tile_walk = I965_TILEWALK_YMAJOR;
751 gen7_pp_set_surface_tiling(struct gen7_surface_state *ss, unsigned int tiling)
754 case I915_TILING_NONE:
755 ss->ss0.tiled_surface = 0;
756 ss->ss0.tile_walk = 0;
759 ss->ss0.tiled_surface = 1;
760 ss->ss0.tile_walk = I965_TILEWALK_XMAJOR;
763 ss->ss0.tiled_surface = 1;
764 ss->ss0.tile_walk = I965_TILEWALK_YMAJOR;
770 gen7_pp_set_surface2_tiling(struct gen7_surface_state2 *ss, unsigned int tiling)
773 case I915_TILING_NONE:
774 ss->ss2.tiled_surface = 0;
775 ss->ss2.tile_walk = 0;
778 ss->ss2.tiled_surface = 1;
779 ss->ss2.tile_walk = I965_TILEWALK_XMAJOR;
782 ss->ss2.tiled_surface = 1;
783 ss->ss2.tile_walk = I965_TILEWALK_YMAJOR;
789 ironlake_pp_interface_descriptor_table(struct i965_post_processing_context *pp_context)
791 struct i965_interface_descriptor *desc;
793 int pp_index = pp_context->current_pp;
795 bo = pp_context->idrt.bo;
799 memset(desc, 0, sizeof(*desc));
800 desc->desc0.grf_reg_blocks = 10;
801 desc->desc0.kernel_start_pointer = pp_context->pp_modules[pp_index].kernel.bo->offset >> 6; /* reloc */
802 desc->desc1.const_urb_entry_read_offset = 0;
803 desc->desc1.const_urb_entry_read_len = 4; /* grf 1-4 */
804 desc->desc2.sampler_state_pointer = pp_context->sampler_state_table.bo->offset >> 5;
805 desc->desc2.sampler_count = 0;
806 desc->desc3.binding_table_entry_count = 0;
807 desc->desc3.binding_table_pointer = (BINDING_TABLE_OFFSET >> 5);
809 dri_bo_emit_reloc(bo,
810 I915_GEM_DOMAIN_INSTRUCTION, 0,
811 desc->desc0.grf_reg_blocks,
812 offsetof(struct i965_interface_descriptor, desc0),
813 pp_context->pp_modules[pp_index].kernel.bo);
815 dri_bo_emit_reloc(bo,
816 I915_GEM_DOMAIN_INSTRUCTION, 0,
817 desc->desc2.sampler_count << 2,
818 offsetof(struct i965_interface_descriptor, desc2),
819 pp_context->sampler_state_table.bo);
822 pp_context->idrt.num_interface_descriptors++;
826 ironlake_pp_vfe_state(struct i965_post_processing_context *pp_context)
828 struct i965_vfe_state *vfe_state;
831 bo = pp_context->vfe_state.bo;
834 vfe_state = bo->virtual;
835 memset(vfe_state, 0, sizeof(*vfe_state));
836 vfe_state->vfe1.max_threads = pp_context->urb.num_vfe_entries - 1;
837 vfe_state->vfe1.urb_entry_alloc_size = pp_context->urb.size_vfe_entry - 1;
838 vfe_state->vfe1.num_urb_entries = pp_context->urb.num_vfe_entries;
839 vfe_state->vfe1.vfe_mode = VFE_GENERIC_MODE;
840 vfe_state->vfe1.children_present = 0;
841 vfe_state->vfe2.interface_descriptor_base =
842 pp_context->idrt.bo->offset >> 4; /* reloc */
843 dri_bo_emit_reloc(bo,
844 I915_GEM_DOMAIN_INSTRUCTION, 0,
846 offsetof(struct i965_vfe_state, vfe2),
847 pp_context->idrt.bo);
852 ironlake_pp_upload_constants(struct i965_post_processing_context *pp_context)
854 unsigned char *constant_buffer;
855 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
857 assert(sizeof(*pp_static_parameter) == 128);
858 dri_bo_map(pp_context->curbe.bo, 1);
859 assert(pp_context->curbe.bo->virtual);
860 constant_buffer = pp_context->curbe.bo->virtual;
861 memcpy(constant_buffer, pp_static_parameter, sizeof(*pp_static_parameter));
862 dri_bo_unmap(pp_context->curbe.bo);
866 ironlake_pp_states_setup(VADriverContextP ctx,
867 struct i965_post_processing_context *pp_context)
869 ironlake_pp_interface_descriptor_table(pp_context);
870 ironlake_pp_vfe_state(pp_context);
871 ironlake_pp_upload_constants(pp_context);
875 ironlake_pp_pipeline_select(VADriverContextP ctx,
876 struct i965_post_processing_context *pp_context)
878 struct intel_batchbuffer *batch = pp_context->batch;
880 BEGIN_BATCH(batch, 1);
881 OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA);
882 ADVANCE_BATCH(batch);
886 ironlake_pp_urb_layout(VADriverContextP ctx,
887 struct i965_post_processing_context *pp_context)
889 struct intel_batchbuffer *batch = pp_context->batch;
890 unsigned int vfe_fence, cs_fence;
892 vfe_fence = pp_context->urb.cs_start;
893 cs_fence = pp_context->urb.size;
895 BEGIN_BATCH(batch, 3);
896 OUT_BATCH(batch, CMD_URB_FENCE | UF0_VFE_REALLOC | UF0_CS_REALLOC | 1);
899 (vfe_fence << UF2_VFE_FENCE_SHIFT) | /* VFE_SIZE */
900 (cs_fence << UF2_CS_FENCE_SHIFT)); /* CS_SIZE */
901 ADVANCE_BATCH(batch);
905 ironlake_pp_state_base_address(VADriverContextP ctx,
906 struct i965_post_processing_context *pp_context)
908 struct intel_batchbuffer *batch = pp_context->batch;
910 BEGIN_BATCH(batch, 8);
911 OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | 6);
912 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
913 OUT_RELOC(batch, pp_context->surface_state_binding_table.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);
914 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
915 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
916 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
917 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
918 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
919 ADVANCE_BATCH(batch);
923 ironlake_pp_state_pointers(VADriverContextP ctx,
924 struct i965_post_processing_context *pp_context)
926 struct intel_batchbuffer *batch = pp_context->batch;
928 BEGIN_BATCH(batch, 3);
929 OUT_BATCH(batch, CMD_MEDIA_STATE_POINTERS | 1);
931 OUT_RELOC(batch, pp_context->vfe_state.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
932 ADVANCE_BATCH(batch);
936 ironlake_pp_cs_urb_layout(VADriverContextP ctx,
937 struct i965_post_processing_context *pp_context)
939 struct intel_batchbuffer *batch = pp_context->batch;
941 BEGIN_BATCH(batch, 2);
942 OUT_BATCH(batch, CMD_CS_URB_STATE | 0);
944 ((pp_context->urb.size_cs_entry - 1) << 4) | /* URB Entry Allocation Size */
945 (pp_context->urb.num_cs_entries << 0)); /* Number of URB Entries */
946 ADVANCE_BATCH(batch);
950 ironlake_pp_constant_buffer(VADriverContextP ctx,
951 struct i965_post_processing_context *pp_context)
953 struct intel_batchbuffer *batch = pp_context->batch;
955 BEGIN_BATCH(batch, 2);
956 OUT_BATCH(batch, CMD_CONSTANT_BUFFER | (1 << 8) | (2 - 2));
957 OUT_RELOC(batch, pp_context->curbe.bo,
958 I915_GEM_DOMAIN_INSTRUCTION, 0,
959 pp_context->urb.size_cs_entry - 1);
960 ADVANCE_BATCH(batch);
964 ironlake_pp_object_walker(VADriverContextP ctx,
965 struct i965_post_processing_context *pp_context)
967 struct intel_batchbuffer *batch = pp_context->batch;
968 int x, x_steps, y, y_steps;
969 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
971 x_steps = pp_context->pp_x_steps(&pp_context->private_context);
972 y_steps = pp_context->pp_y_steps(&pp_context->private_context);
974 for (y = 0; y < y_steps; y++) {
975 for (x = 0; x < x_steps; x++) {
976 if (!pp_context->pp_set_block_parameter(pp_context, x, y)) {
977 BEGIN_BATCH(batch, 20);
978 OUT_BATCH(batch, CMD_MEDIA_OBJECT | 18);
980 OUT_BATCH(batch, 0); /* no indirect data */
983 /* inline data grf 5-6 */
984 assert(sizeof(*pp_inline_parameter) == 64);
985 intel_batchbuffer_data(batch, pp_inline_parameter, sizeof(*pp_inline_parameter));
987 ADVANCE_BATCH(batch);
994 ironlake_pp_pipeline_setup(VADriverContextP ctx,
995 struct i965_post_processing_context *pp_context)
997 struct intel_batchbuffer *batch = pp_context->batch;
999 intel_batchbuffer_start_atomic(batch, 0x1000);
1000 intel_batchbuffer_emit_mi_flush(batch);
1001 ironlake_pp_pipeline_select(ctx, pp_context);
1002 ironlake_pp_state_base_address(ctx, pp_context);
1003 ironlake_pp_state_pointers(ctx, pp_context);
1004 ironlake_pp_urb_layout(ctx, pp_context);
1005 ironlake_pp_cs_urb_layout(ctx, pp_context);
1006 ironlake_pp_constant_buffer(ctx, pp_context);
1007 ironlake_pp_object_walker(ctx, pp_context);
1008 intel_batchbuffer_end_atomic(batch);
1012 i965_pp_set_surface_state(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1013 dri_bo *surf_bo, unsigned long surf_bo_offset,
1014 int width, int height, int pitch, int format,
1015 int index, int is_target)
1017 struct i965_surface_state *ss;
1019 unsigned int tiling;
1020 unsigned int swizzle;
1022 dri_bo_get_tiling(surf_bo, &tiling, &swizzle);
1023 ss_bo = pp_context->surface_state_binding_table.bo;
1026 dri_bo_map(ss_bo, True);
1027 assert(ss_bo->virtual);
1028 ss = (struct i965_surface_state *)((char *)ss_bo->virtual + SURFACE_STATE_OFFSET(index));
1029 memset(ss, 0, sizeof(*ss));
1030 ss->ss0.surface_type = I965_SURFACE_2D;
1031 ss->ss0.surface_format = format;
1032 ss->ss1.base_addr = surf_bo->offset + surf_bo_offset;
1033 ss->ss2.width = width - 1;
1034 ss->ss2.height = height - 1;
1035 ss->ss3.pitch = pitch - 1;
1036 pp_set_surface_tiling(ss, tiling);
1037 dri_bo_emit_reloc(ss_bo,
1038 I915_GEM_DOMAIN_RENDER, is_target ? I915_GEM_DOMAIN_RENDER : 0,
1040 SURFACE_STATE_OFFSET(index) + offsetof(struct i965_surface_state, ss1),
1042 ((unsigned int *)((char *)ss_bo->virtual + BINDING_TABLE_OFFSET))[index] = SURFACE_STATE_OFFSET(index);
1043 dri_bo_unmap(ss_bo);
1047 i965_pp_set_surface2_state(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1048 dri_bo *surf_bo, unsigned long surf_bo_offset,
1049 int width, int height, int wpitch,
1050 int xoffset, int yoffset,
1051 int format, int interleave_chroma,
1054 struct i965_surface_state2 *ss2;
1056 unsigned int tiling;
1057 unsigned int swizzle;
1059 dri_bo_get_tiling(surf_bo, &tiling, &swizzle);
1060 ss2_bo = pp_context->surface_state_binding_table.bo;
1063 dri_bo_map(ss2_bo, True);
1064 assert(ss2_bo->virtual);
1065 ss2 = (struct i965_surface_state2 *)((char *)ss2_bo->virtual + SURFACE_STATE_OFFSET(index));
1066 memset(ss2, 0, sizeof(*ss2));
1067 ss2->ss0.surface_base_address = surf_bo->offset + surf_bo_offset;
1068 ss2->ss1.cbcr_pixel_offset_v_direction = 0;
1069 ss2->ss1.width = width - 1;
1070 ss2->ss1.height = height - 1;
1071 ss2->ss2.pitch = wpitch - 1;
1072 ss2->ss2.interleave_chroma = interleave_chroma;
1073 ss2->ss2.surface_format = format;
1074 ss2->ss3.x_offset_for_cb = xoffset;
1075 ss2->ss3.y_offset_for_cb = yoffset;
1076 pp_set_surface2_tiling(ss2, tiling);
1077 dri_bo_emit_reloc(ss2_bo,
1078 I915_GEM_DOMAIN_RENDER, 0,
1080 SURFACE_STATE_OFFSET(index) + offsetof(struct i965_surface_state2, ss0),
1082 ((unsigned int *)((char *)ss2_bo->virtual + BINDING_TABLE_OFFSET))[index] = SURFACE_STATE_OFFSET(index);
1083 dri_bo_unmap(ss2_bo);
1087 gen7_pp_set_surface_state(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1088 dri_bo *surf_bo, unsigned long surf_bo_offset,
1089 int width, int height, int pitch, int format,
1090 int index, int is_target)
1092 struct gen7_surface_state *ss;
1094 unsigned int tiling;
1095 unsigned int swizzle;
1097 dri_bo_get_tiling(surf_bo, &tiling, &swizzle);
1098 ss_bo = pp_context->surface_state_binding_table.bo;
1101 dri_bo_map(ss_bo, True);
1102 assert(ss_bo->virtual);
1103 ss = (struct gen7_surface_state *)((char *)ss_bo->virtual + SURFACE_STATE_OFFSET(index));
1104 memset(ss, 0, sizeof(*ss));
1105 ss->ss0.surface_type = I965_SURFACE_2D;
1106 ss->ss0.surface_format = format;
1107 ss->ss1.base_addr = surf_bo->offset + surf_bo_offset;
1108 ss->ss2.width = width - 1;
1109 ss->ss2.height = height - 1;
1110 ss->ss3.pitch = pitch - 1;
1111 gen7_pp_set_surface_tiling(ss, tiling);
1112 dri_bo_emit_reloc(ss_bo,
1113 I915_GEM_DOMAIN_RENDER, is_target ? I915_GEM_DOMAIN_RENDER : 0,
1115 SURFACE_STATE_OFFSET(index) + offsetof(struct gen7_surface_state, ss1),
1117 ((unsigned int *)((char *)ss_bo->virtual + BINDING_TABLE_OFFSET))[index] = SURFACE_STATE_OFFSET(index);
1118 dri_bo_unmap(ss_bo);
1122 gen7_pp_set_surface2_state(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1123 dri_bo *surf_bo, unsigned long surf_bo_offset,
1124 int width, int height, int wpitch,
1125 int xoffset, int yoffset,
1126 int format, int interleave_chroma,
1129 struct gen7_surface_state2 *ss2;
1131 unsigned int tiling;
1132 unsigned int swizzle;
1134 dri_bo_get_tiling(surf_bo, &tiling, &swizzle);
1135 ss2_bo = pp_context->surface_state_binding_table.bo;
1138 dri_bo_map(ss2_bo, True);
1139 assert(ss2_bo->virtual);
1140 ss2 = (struct gen7_surface_state2 *)((char *)ss2_bo->virtual + SURFACE_STATE_OFFSET(index));
1141 memset(ss2, 0, sizeof(*ss2));
1142 ss2->ss0.surface_base_address = surf_bo->offset + surf_bo_offset;
1143 ss2->ss1.cbcr_pixel_offset_v_direction = 0;
1144 ss2->ss1.width = width - 1;
1145 ss2->ss1.height = height - 1;
1146 ss2->ss2.pitch = wpitch - 1;
1147 ss2->ss2.interleave_chroma = interleave_chroma;
1148 ss2->ss2.surface_format = format;
1149 ss2->ss3.x_offset_for_cb = xoffset;
1150 ss2->ss3.y_offset_for_cb = yoffset;
1151 gen7_pp_set_surface2_tiling(ss2, tiling);
1152 dri_bo_emit_reloc(ss2_bo,
1153 I915_GEM_DOMAIN_RENDER, 0,
1155 SURFACE_STATE_OFFSET(index) + offsetof(struct gen7_surface_state2, ss0),
1157 ((unsigned int *)((char *)ss2_bo->virtual + BINDING_TABLE_OFFSET))[index] = SURFACE_STATE_OFFSET(index);
1158 dri_bo_unmap(ss2_bo);
1162 pp_set_media_rw_message_surface(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1163 const struct i965_surface *surface,
1164 int base_index, int is_target,
1165 int *width, int *height, int *pitch, int *offset)
1167 struct i965_driver_data *i965 = i965_driver_data(ctx);
1168 struct object_surface *obj_surface;
1169 struct object_image *obj_image;
1171 int fourcc = pp_get_surface_fourcc(ctx, surface);
1173 const int U = fourcc == VA_FOURCC('Y', 'V', '1', '2') ? 2 : 1;
1174 const int V = fourcc == VA_FOURCC('Y', 'V', '1', '2') ? 1 : 2;
1176 int interleaved_uv = fourcc == VA_FOURCC('N', 'V', '1', '2');
1177 int packed_yuv = (fourcc == VA_FOURCC('Y', 'U', 'Y', '2') || fourcc == VA_FOURCC('U', 'Y', 'V', 'Y'));
1179 if (surface->type == I965_SURFACE_TYPE_SURFACE) {
1180 obj_surface = SURFACE(surface->id);
1181 bo = obj_surface->bo;
1182 width[0] = obj_surface->orig_width;
1183 height[0] = obj_surface->orig_height;
1184 pitch[0] = obj_surface->width;
1188 width[0] = obj_surface->orig_width * 2;
1189 pitch[0] = obj_surface->width * 2;
1191 else if (interleaved_uv) {
1192 width[1] = obj_surface->orig_width;
1193 height[1] = obj_surface->orig_height / 2;
1194 pitch[1] = obj_surface->width;
1195 offset[1] = offset[0] + obj_surface->width * obj_surface->height;
1197 width[1] = obj_surface->orig_width / 2;
1198 height[1] = obj_surface->orig_height / 2;
1199 pitch[1] = obj_surface->width / 2;
1200 offset[1] = offset[0] + obj_surface->width * obj_surface->height;
1201 width[2] = obj_surface->orig_width / 2;
1202 height[2] = obj_surface->orig_height / 2;
1203 pitch[2] = obj_surface->width / 2;
1204 offset[2] = offset[1] + (obj_surface->width / 2) * (obj_surface->height / 2);
1207 obj_image = IMAGE(surface->id);
1209 width[0] = obj_image->image.width;
1210 height[0] = obj_image->image.height;
1211 pitch[0] = obj_image->image.pitches[0];
1212 offset[0] = obj_image->image.offsets[0];
1214 if (interleaved_uv) {
1215 width[1] = obj_image->image.width;
1216 height[1] = obj_image->image.height / 2;
1217 pitch[1] = obj_image->image.pitches[1];
1218 offset[1] = obj_image->image.offsets[1];
1220 width[1] = obj_image->image.width / 2;
1221 height[1] = obj_image->image.height / 2;
1222 pitch[1] = obj_image->image.pitches[1];
1223 offset[1] = obj_image->image.offsets[1];
1224 width[2] = obj_image->image.width / 2;
1225 height[2] = obj_image->image.height / 2;
1226 pitch[2] = obj_image->image.pitches[2];
1227 offset[2] = obj_image->image.offsets[2];
1232 i965_pp_set_surface_state(ctx, pp_context,
1234 width[Y] / 4, height[Y], pitch[Y], I965_SURFACEFORMAT_R8_UNORM,
1235 base_index, is_target);
1238 if (interleaved_uv) {
1239 i965_pp_set_surface_state(ctx, pp_context,
1241 width[UV] / 4, height[UV], pitch[UV], I965_SURFACEFORMAT_R8_UNORM,
1242 base_index + 1, is_target);
1245 i965_pp_set_surface_state(ctx, pp_context,
1247 width[U] / 4, height[U], pitch[U], I965_SURFACEFORMAT_R8_UNORM,
1248 base_index + 1, is_target);
1251 i965_pp_set_surface_state(ctx, pp_context,
1253 width[V] / 4, height[V], pitch[V], I965_SURFACEFORMAT_R8_UNORM,
1254 base_index + 2, is_target);
1261 gen7_pp_set_media_rw_message_surface(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1262 const struct i965_surface *surface,
1263 int base_index, int is_target,
1264 int *width, int *height, int *pitch, int *offset)
1266 struct i965_driver_data *i965 = i965_driver_data(ctx);
1267 struct object_surface *obj_surface;
1268 struct object_image *obj_image;
1270 int fourcc = pp_get_surface_fourcc(ctx, surface);
1271 const int U = (fourcc == VA_FOURCC('Y', 'V', '1', '2') ||
1272 fourcc == VA_FOURCC('I', 'M', 'C', '1')) ? 2 : 1;
1273 const int V = (fourcc == VA_FOURCC('Y', 'V', '1', '2') ||
1274 fourcc == VA_FOURCC('I', 'M', 'C', '1')) ? 1 : 2;
1275 int interleaved_uv = fourcc == VA_FOURCC('N', 'V', '1', '2');
1277 if (surface->type == I965_SURFACE_TYPE_SURFACE) {
1278 obj_surface = SURFACE(surface->id);
1279 bo = obj_surface->bo;
1280 width[0] = obj_surface->orig_width;
1281 height[0] = obj_surface->orig_height;
1282 pitch[0] = obj_surface->width;
1285 width[1] = obj_surface->cb_cr_width;
1286 height[1] = obj_surface->cb_cr_height;
1287 pitch[1] = obj_surface->cb_cr_pitch;
1288 offset[1] = obj_surface->y_cb_offset * obj_surface->width;
1290 width[2] = obj_surface->cb_cr_width;
1291 height[2] = obj_surface->cb_cr_height;
1292 pitch[2] = obj_surface->cb_cr_pitch;
1293 offset[2] = obj_surface->y_cr_offset * obj_surface->width;
1295 obj_image = IMAGE(surface->id);
1297 width[0] = obj_image->image.width;
1298 height[0] = obj_image->image.height;
1299 pitch[0] = obj_image->image.pitches[0];
1300 offset[0] = obj_image->image.offsets[0];
1302 if (interleaved_uv) {
1303 width[1] = obj_image->image.width;
1304 height[1] = obj_image->image.height / 2;
1305 pitch[1] = obj_image->image.pitches[1];
1306 offset[1] = obj_image->image.offsets[1];
1308 width[1] = obj_image->image.width / 2;
1309 height[1] = obj_image->image.height / 2;
1310 pitch[1] = obj_image->image.pitches[U];
1311 offset[1] = obj_image->image.offsets[U];
1312 width[2] = obj_image->image.width / 2;
1313 height[2] = obj_image->image.height / 2;
1314 pitch[2] = obj_image->image.pitches[V];
1315 offset[2] = obj_image->image.offsets[V];
1320 gen7_pp_set_surface_state(ctx, pp_context,
1322 width[0] / 4, height[0], pitch[0],
1323 I965_SURFACEFORMAT_R8_SINT,
1326 if (interleaved_uv) {
1327 gen7_pp_set_surface_state(ctx, pp_context,
1329 width[1] / 2, height[1], pitch[1],
1330 I965_SURFACEFORMAT_R8G8_SINT,
1333 gen7_pp_set_surface_state(ctx, pp_context,
1335 width[1] / 4, height[1], pitch[1],
1336 I965_SURFACEFORMAT_R8_SINT,
1338 gen7_pp_set_surface_state(ctx, pp_context,
1340 width[2] / 4, height[2], pitch[2],
1341 I965_SURFACEFORMAT_R8_SINT,
1345 gen7_pp_set_surface2_state(ctx, pp_context,
1347 width[0], height[0], pitch[0],
1349 SURFACE_FORMAT_Y8_UNORM, 0,
1352 if (interleaved_uv) {
1353 gen7_pp_set_surface2_state(ctx, pp_context,
1355 width[1], height[1], pitch[1],
1357 SURFACE_FORMAT_R8B8_UNORM, 0,
1360 gen7_pp_set_surface2_state(ctx, pp_context,
1362 width[1], height[1], pitch[1],
1364 SURFACE_FORMAT_R8_UNORM, 0,
1366 gen7_pp_set_surface2_state(ctx, pp_context,
1368 width[2], height[2], pitch[2],
1370 SURFACE_FORMAT_R8_UNORM, 0,
1377 pp_null_x_steps(void *private_context)
1383 pp_null_y_steps(void *private_context)
1389 pp_null_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
1395 pp_null_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1396 const struct i965_surface *src_surface,
1397 const VARectangle *src_rect,
1398 struct i965_surface *dst_surface,
1399 const VARectangle *dst_rect,
1402 /* private function & data */
1403 pp_context->pp_x_steps = pp_null_x_steps;
1404 pp_context->pp_y_steps = pp_null_y_steps;
1405 pp_context->pp_set_block_parameter = pp_null_set_block_parameter;
1407 dst_surface->flags = src_surface->flags;
1409 return VA_STATUS_SUCCESS;
1413 pp_load_save_x_steps(void *private_context)
1419 pp_load_save_y_steps(void *private_context)
1421 struct pp_load_save_context *pp_load_save_context = private_context;
1423 return pp_load_save_context->dest_h / 8;
1427 pp_load_save_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
1429 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1431 pp_inline_parameter->grf5.block_vertical_mask = 0xff;
1432 pp_inline_parameter->grf5.block_horizontal_mask = 0xffff;
1433 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16;
1434 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 8;
1440 pp_plx_load_save_plx_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1441 const struct i965_surface *src_surface,
1442 const VARectangle *src_rect,
1443 struct i965_surface *dst_surface,
1444 const VARectangle *dst_rect,
1447 struct pp_load_save_context *pp_load_save_context = (struct pp_load_save_context *)&pp_context->private_context;
1448 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1449 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1450 int width[3], height[3], pitch[3], offset[3];
1453 /* source surface */
1454 pp_set_media_rw_message_surface(ctx, pp_context, src_surface, 1, 0,
1455 width, height, pitch, offset);
1457 /* destination surface */
1458 pp_set_media_rw_message_surface(ctx, pp_context, dst_surface, 7, 1,
1459 width, height, pitch, offset);
1461 /* private function & data */
1462 pp_context->pp_x_steps = pp_load_save_x_steps;
1463 pp_context->pp_y_steps = pp_load_save_y_steps;
1464 pp_context->pp_set_block_parameter = pp_load_save_set_block_parameter;
1465 pp_load_save_context->dest_h = ALIGN(height[Y], 16);
1466 pp_load_save_context->dest_w = ALIGN(width[Y], 16);
1468 pp_inline_parameter->grf5.block_count_x = ALIGN(width[Y], 16) / 16; /* 1 x N */
1469 pp_inline_parameter->grf5.number_blocks = ALIGN(width[Y], 16) / 16;
1471 pp_static_parameter->grf3.horizontal_origin_offset = src_rect->x;
1472 pp_static_parameter->grf3.vertical_origin_offset = src_rect->y;
1474 dst_surface->flags = src_surface->flags;
1476 return VA_STATUS_SUCCESS;
1480 pp_scaling_x_steps(void *private_context)
1486 pp_scaling_y_steps(void *private_context)
1488 struct pp_scaling_context *pp_scaling_context = private_context;
1490 return pp_scaling_context->dest_h / 8;
1494 pp_scaling_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
1496 struct pp_scaling_context *pp_scaling_context = (struct pp_scaling_context *)&pp_context->private_context;
1497 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1498 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1499 float src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1500 float src_y_steping = pp_static_parameter->grf1.r1_6.normalized_video_y_scaling_step;
1502 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin = src_x_steping * x * 16 + pp_scaling_context->src_normalized_x;
1503 pp_inline_parameter->grf5.source_surface_block_normalized_vertical_origin = src_y_steping * y * 8 + pp_scaling_context->src_normalized_y;
1504 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16 + pp_scaling_context->dest_x;
1505 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 8 + pp_scaling_context->dest_y;
1511 pp_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1512 const struct i965_surface *src_surface,
1513 const VARectangle *src_rect,
1514 struct i965_surface *dst_surface,
1515 const VARectangle *dst_rect,
1518 struct i965_driver_data *i965 = i965_driver_data(ctx);
1519 struct pp_scaling_context *pp_scaling_context = (struct pp_scaling_context *)&pp_context->private_context;
1520 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1521 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1522 struct object_surface *obj_surface;
1523 struct i965_sampler_state *sampler_state;
1524 int in_w, in_h, in_wpitch, in_hpitch;
1525 int out_w, out_h, out_wpitch, out_hpitch;
1527 /* source surface */
1528 obj_surface = SURFACE(src_surface->id);
1529 in_w = obj_surface->orig_width;
1530 in_h = obj_surface->orig_height;
1531 in_wpitch = obj_surface->width;
1532 in_hpitch = obj_surface->height;
1534 /* source Y surface index 1 */
1535 i965_pp_set_surface_state(ctx, pp_context,
1537 in_w, in_h, in_wpitch, I965_SURFACEFORMAT_R8_UNORM,
1540 /* source UV surface index 2 */
1541 i965_pp_set_surface_state(ctx, pp_context,
1542 obj_surface->bo, in_wpitch * in_hpitch,
1543 in_w / 2, in_h / 2, in_wpitch, I965_SURFACEFORMAT_R8G8_UNORM,
1546 /* destination surface */
1547 obj_surface = SURFACE(dst_surface->id);
1548 out_w = obj_surface->orig_width;
1549 out_h = obj_surface->orig_height;
1550 out_wpitch = obj_surface->width;
1551 out_hpitch = obj_surface->height;
1553 /* destination Y surface index 7 */
1554 i965_pp_set_surface_state(ctx, pp_context,
1556 out_w / 4, out_h, out_wpitch, I965_SURFACEFORMAT_R8_UNORM,
1559 /* destination UV surface index 8 */
1560 i965_pp_set_surface_state(ctx, pp_context,
1561 obj_surface->bo, out_wpitch * out_hpitch,
1562 out_w / 4, out_h / 2, out_wpitch, I965_SURFACEFORMAT_R8G8_UNORM,
1566 dri_bo_map(pp_context->sampler_state_table.bo, True);
1567 assert(pp_context->sampler_state_table.bo->virtual);
1568 sampler_state = pp_context->sampler_state_table.bo->virtual;
1570 /* SIMD16 Y index 1 */
1571 sampler_state[1].ss0.min_filter = I965_MAPFILTER_LINEAR;
1572 sampler_state[1].ss0.mag_filter = I965_MAPFILTER_LINEAR;
1573 sampler_state[1].ss1.r_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1574 sampler_state[1].ss1.s_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1575 sampler_state[1].ss1.t_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1577 /* SIMD16 UV index 2 */
1578 sampler_state[2].ss0.min_filter = I965_MAPFILTER_LINEAR;
1579 sampler_state[2].ss0.mag_filter = I965_MAPFILTER_LINEAR;
1580 sampler_state[2].ss1.r_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1581 sampler_state[2].ss1.s_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1582 sampler_state[2].ss1.t_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1584 dri_bo_unmap(pp_context->sampler_state_table.bo);
1586 /* private function & data */
1587 pp_context->pp_x_steps = pp_scaling_x_steps;
1588 pp_context->pp_y_steps = pp_scaling_y_steps;
1589 pp_context->pp_set_block_parameter = pp_scaling_set_block_parameter;
1591 pp_scaling_context->dest_x = dst_rect->x;
1592 pp_scaling_context->dest_y = dst_rect->y;
1593 pp_scaling_context->dest_w = ALIGN(dst_rect->width, 16);
1594 pp_scaling_context->dest_h = ALIGN(dst_rect->height, 16);
1595 pp_scaling_context->src_normalized_x = (float)src_rect->x / in_w;
1596 pp_scaling_context->src_normalized_y = (float)src_rect->y / in_h;
1598 pp_static_parameter->grf1.r1_6.normalized_video_y_scaling_step = (float) src_rect->height / in_h / dst_rect->height;
1600 pp_inline_parameter->grf5.normalized_video_x_scaling_step = (float) src_rect->width / in_w / dst_rect->width;
1601 pp_inline_parameter->grf5.block_count_x = pp_scaling_context->dest_w / 16; /* 1 x N */
1602 pp_inline_parameter->grf5.number_blocks = pp_scaling_context->dest_w / 16;
1603 pp_inline_parameter->grf5.block_vertical_mask = 0xff;
1604 pp_inline_parameter->grf5.block_horizontal_mask = 0xffff;
1606 dst_surface->flags = src_surface->flags;
1608 return VA_STATUS_SUCCESS;
1612 pp_avs_x_steps(void *private_context)
1614 struct pp_avs_context *pp_avs_context = private_context;
1616 return pp_avs_context->dest_w / 16;
1620 pp_avs_y_steps(void *private_context)
1626 pp_avs_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
1628 struct pp_avs_context *pp_avs_context = (struct pp_avs_context *)&pp_context->private_context;
1629 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1630 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1631 float src_x_steping, src_y_steping, video_step_delta;
1632 int tmp_w = ALIGN(pp_avs_context->dest_h * pp_avs_context->src_w / pp_avs_context->src_h, 16);
1634 if (pp_static_parameter->grf4.r4_2.avs.nlas == 0) {
1635 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1636 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin = src_x_steping * x * 16 + pp_avs_context->src_normalized_x;
1637 } else if (tmp_w >= pp_avs_context->dest_w) {
1638 pp_inline_parameter->grf5.normalized_video_x_scaling_step = 1.0 / tmp_w;
1639 pp_inline_parameter->grf6.video_step_delta = 0;
1642 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin = (float)(tmp_w - pp_avs_context->dest_w) / tmp_w / 2 +
1643 pp_avs_context->src_normalized_x;
1645 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1646 video_step_delta = pp_inline_parameter->grf6.video_step_delta;
1647 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin += src_x_steping * 16 +
1648 16 * 15 * video_step_delta / 2;
1651 int n0, n1, n2, nls_left, nls_right;
1652 int factor_a = 5, factor_b = 4;
1655 n0 = (pp_avs_context->dest_w - tmp_w) / (16 * 2);
1656 n1 = (pp_avs_context->dest_w - tmp_w) / 16 - n0;
1657 n2 = tmp_w / (16 * factor_a);
1659 nls_right = n1 + n2;
1660 f = (float) n2 * 16 / tmp_w;
1663 pp_inline_parameter->grf6.video_step_delta = 0.0;
1666 pp_inline_parameter->grf5.normalized_video_x_scaling_step = 1.0 / pp_avs_context->dest_w;
1667 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin = pp_avs_context->src_normalized_x;
1669 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1670 video_step_delta = pp_inline_parameter->grf6.video_step_delta;
1671 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin += src_x_steping * 16 +
1672 16 * 15 * video_step_delta / 2;
1676 /* f = a * nls_left * 16 + b * nls_left * 16 * (nls_left * 16 - 1) / 2 */
1677 float a = f / (nls_left * 16 * factor_b);
1678 float b = (f - nls_left * 16 * a) * 2 / (nls_left * 16 * (nls_left * 16 - 1));
1680 pp_inline_parameter->grf6.video_step_delta = b;
1683 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin = pp_avs_context->src_normalized_x;
1684 pp_inline_parameter->grf5.normalized_video_x_scaling_step = a;
1686 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1687 video_step_delta = pp_inline_parameter->grf6.video_step_delta;
1688 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin += src_x_steping * 16 +
1689 16 * 15 * video_step_delta / 2;
1690 pp_inline_parameter->grf5.normalized_video_x_scaling_step += 16 * b;
1692 } else if (x < (pp_avs_context->dest_w / 16 - nls_right)) {
1693 /* scale the center linearly */
1694 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1695 video_step_delta = pp_inline_parameter->grf6.video_step_delta;
1696 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin += src_x_steping * 16 +
1697 16 * 15 * video_step_delta / 2;
1698 pp_inline_parameter->grf6.video_step_delta = 0.0;
1699 pp_inline_parameter->grf5.normalized_video_x_scaling_step = 1.0 / tmp_w;
1701 float a = f / (nls_right * 16 * factor_b);
1702 float b = (f - nls_right * 16 * a) * 2 / (nls_right * 16 * (nls_right * 16 - 1));
1704 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1705 video_step_delta = pp_inline_parameter->grf6.video_step_delta;
1706 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin += src_x_steping * 16 +
1707 16 * 15 * video_step_delta / 2;
1708 pp_inline_parameter->grf6.video_step_delta = -b;
1710 if (x == (pp_avs_context->dest_w / 16 - nls_right))
1711 pp_inline_parameter->grf5.normalized_video_x_scaling_step = a + (nls_right * 16 - 1) * b;
1713 pp_inline_parameter->grf5.normalized_video_x_scaling_step -= b * 16;
1718 src_y_steping = pp_static_parameter->grf1.r1_6.normalized_video_y_scaling_step;
1719 pp_inline_parameter->grf5.source_surface_block_normalized_vertical_origin = src_y_steping * y * 8 + pp_avs_context->src_normalized_y;
1720 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16 + pp_avs_context->dest_x;
1721 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 8 + pp_avs_context->dest_y;
1727 pp_nv12_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1728 const struct i965_surface *src_surface,
1729 const VARectangle *src_rect,
1730 struct i965_surface *dst_surface,
1731 const VARectangle *dst_rect,
1735 struct i965_driver_data *i965 = i965_driver_data(ctx);
1736 struct pp_avs_context *pp_avs_context = (struct pp_avs_context *)&pp_context->private_context;
1737 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1738 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1739 struct object_surface *obj_surface;
1740 struct i965_sampler_8x8 *sampler_8x8;
1741 struct i965_sampler_8x8_state *sampler_8x8_state;
1743 int in_w, in_h, in_wpitch, in_hpitch;
1744 int out_w, out_h, out_wpitch, out_hpitch;
1748 obj_surface = SURFACE(src_surface->id);
1749 in_w = obj_surface->orig_width;
1750 in_h = obj_surface->orig_height;
1751 in_wpitch = obj_surface->width;
1752 in_hpitch = obj_surface->height;
1754 /* source Y surface index 1 */
1755 i965_pp_set_surface2_state(ctx, pp_context,
1757 in_w, in_h, in_wpitch,
1759 SURFACE_FORMAT_Y8_UNORM, 0,
1762 /* source UV surface index 2 */
1763 i965_pp_set_surface2_state(ctx, pp_context,
1764 obj_surface->bo, in_wpitch * in_hpitch,
1765 in_w / 2, in_h / 2, in_wpitch,
1767 SURFACE_FORMAT_R8B8_UNORM, 0,
1770 /* destination surface */
1771 obj_surface = SURFACE(dst_surface->id);
1772 out_w = obj_surface->orig_width;
1773 out_h = obj_surface->orig_height;
1774 out_wpitch = obj_surface->width;
1775 out_hpitch = obj_surface->height;
1776 assert(out_w <= out_wpitch && out_h <= out_hpitch);
1778 /* destination Y surface index 7 */
1779 i965_pp_set_surface_state(ctx, pp_context,
1781 out_w / 4, out_h, out_wpitch, I965_SURFACEFORMAT_R8_UNORM,
1784 /* destination UV surface index 8 */
1785 i965_pp_set_surface_state(ctx, pp_context,
1786 obj_surface->bo, out_wpitch * out_hpitch,
1787 out_w / 4, out_h / 2, out_wpitch, I965_SURFACEFORMAT_R8G8_UNORM,
1790 /* sampler 8x8 state */
1791 dri_bo_map(pp_context->sampler_state_table.bo_8x8, True);
1792 assert(pp_context->sampler_state_table.bo_8x8->virtual);
1793 assert(sizeof(*sampler_8x8_state) == sizeof(int) * 138);
1794 sampler_8x8_state = pp_context->sampler_state_table.bo_8x8->virtual;
1795 memset(sampler_8x8_state, 0, sizeof(*sampler_8x8_state));
1797 for (i = 0; i < 17; i++) {
1798 /* for Y channel, currently ignore */
1799 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c0 = 0x00;
1800 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c1 = 0x00;
1801 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c2 = 0x08;
1802 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c3 = 0x18;
1803 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c4 = 0x18;
1804 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c5 = 0x08;
1805 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c6 = 0x00;
1806 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c7 = 0x00;
1807 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c0 = 0x00;
1808 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c1 = 0x00;
1809 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c2 = 0x10;
1810 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c3 = 0x10;
1811 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c4 = 0x10;
1812 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c5 = 0x10;
1813 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c6 = 0x00;
1814 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c7 = 0x00;
1815 /* for U/V channel, 0.25 */
1816 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c0 = 0x0;
1817 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c1 = 0x0;
1818 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c2 = 0x10;
1819 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c3 = 0x10;
1820 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c4 = 0x10;
1821 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c5 = 0x10;
1822 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c6 = 0x0;
1823 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c7 = 0x0;
1824 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c0 = 0x0;
1825 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c1 = 0x0;
1826 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c2 = 0x10;
1827 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c3 = 0x10;
1828 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c4 = 0x10;
1829 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c5 = 0x10;
1830 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c6 = 0x0;
1831 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c7 = 0x0;
1834 sampler_8x8_state->dw136.default_sharpness_level = 0;
1835 sampler_8x8_state->dw137.adaptive_filter_for_all_channel = 1;
1836 sampler_8x8_state->dw137.bypass_y_adaptive_filtering = 1;
1837 sampler_8x8_state->dw137.bypass_x_adaptive_filtering = 1;
1838 dri_bo_unmap(pp_context->sampler_state_table.bo_8x8);
1841 dri_bo_map(pp_context->sampler_state_table.bo, True);
1842 assert(pp_context->sampler_state_table.bo->virtual);
1843 assert(sizeof(*sampler_8x8) == sizeof(int) * 16);
1844 sampler_8x8 = pp_context->sampler_state_table.bo->virtual;
1846 /* sample_8x8 Y index 1 */
1848 memset(&sampler_8x8[index], 0, sizeof(*sampler_8x8));
1849 sampler_8x8[index].dw0.avs_filter_type = AVS_FILTER_ADAPTIVE_8_TAP;
1850 sampler_8x8[index].dw0.ief_bypass = 1;
1851 sampler_8x8[index].dw0.ief_filter_type = IEF_FILTER_DETAIL;
1852 sampler_8x8[index].dw0.ief_filter_size = IEF_FILTER_SIZE_5X5;
1853 sampler_8x8[index].dw1.sampler_8x8_state_pointer = pp_context->sampler_state_table.bo_8x8->offset >> 5;
1854 sampler_8x8[index].dw2.global_noise_estimation = 22;
1855 sampler_8x8[index].dw2.strong_edge_threshold = 8;
1856 sampler_8x8[index].dw2.weak_edge_threshold = 1;
1857 sampler_8x8[index].dw3.strong_edge_weight = 7;
1858 sampler_8x8[index].dw3.regular_weight = 2;
1859 sampler_8x8[index].dw3.non_edge_weight = 0;
1860 sampler_8x8[index].dw3.gain_factor = 40;
1861 sampler_8x8[index].dw4.steepness_boost = 0;
1862 sampler_8x8[index].dw4.steepness_threshold = 0;
1863 sampler_8x8[index].dw4.mr_boost = 0;
1864 sampler_8x8[index].dw4.mr_threshold = 5;
1865 sampler_8x8[index].dw5.pwl1_point_1 = 4;
1866 sampler_8x8[index].dw5.pwl1_point_2 = 12;
1867 sampler_8x8[index].dw5.pwl1_point_3 = 16;
1868 sampler_8x8[index].dw5.pwl1_point_4 = 26;
1869 sampler_8x8[index].dw6.pwl1_point_5 = 40;
1870 sampler_8x8[index].dw6.pwl1_point_6 = 160;
1871 sampler_8x8[index].dw6.pwl1_r3_bias_0 = 127;
1872 sampler_8x8[index].dw6.pwl1_r3_bias_1 = 98;
1873 sampler_8x8[index].dw7.pwl1_r3_bias_2 = 88;
1874 sampler_8x8[index].dw7.pwl1_r3_bias_3 = 64;
1875 sampler_8x8[index].dw7.pwl1_r3_bias_4 = 44;
1876 sampler_8x8[index].dw7.pwl1_r3_bias_5 = 0;
1877 sampler_8x8[index].dw8.pwl1_r3_bias_6 = 0;
1878 sampler_8x8[index].dw8.pwl1_r5_bias_0 = 3;
1879 sampler_8x8[index].dw8.pwl1_r5_bias_1 = 32;
1880 sampler_8x8[index].dw8.pwl1_r5_bias_2 = 32;
1881 sampler_8x8[index].dw9.pwl1_r5_bias_3 = 58;
1882 sampler_8x8[index].dw9.pwl1_r5_bias_4 = 100;
1883 sampler_8x8[index].dw9.pwl1_r5_bias_5 = 108;
1884 sampler_8x8[index].dw9.pwl1_r5_bias_6 = 88;
1885 sampler_8x8[index].dw10.pwl1_r3_slope_0 = -116;
1886 sampler_8x8[index].dw10.pwl1_r3_slope_1 = -20;
1887 sampler_8x8[index].dw10.pwl1_r3_slope_2 = -96;
1888 sampler_8x8[index].dw10.pwl1_r3_slope_3 = -32;
1889 sampler_8x8[index].dw11.pwl1_r3_slope_4 = -50;
1890 sampler_8x8[index].dw11.pwl1_r3_slope_5 = 0;
1891 sampler_8x8[index].dw11.pwl1_r3_slope_6 = 0;
1892 sampler_8x8[index].dw11.pwl1_r5_slope_0 = 116;
1893 sampler_8x8[index].dw12.pwl1_r5_slope_1 = 0;
1894 sampler_8x8[index].dw12.pwl1_r5_slope_2 = 114;
1895 sampler_8x8[index].dw12.pwl1_r5_slope_3 = 67;
1896 sampler_8x8[index].dw12.pwl1_r5_slope_4 = 9;
1897 sampler_8x8[index].dw13.pwl1_r5_slope_5 = -3;
1898 sampler_8x8[index].dw13.pwl1_r5_slope_6 = -15;
1899 sampler_8x8[index].dw13.limiter_boost = 0;
1900 sampler_8x8[index].dw13.minimum_limiter = 10;
1901 sampler_8x8[index].dw13.maximum_limiter = 11;
1902 sampler_8x8[index].dw14.clip_limiter = 130;
1903 dri_bo_emit_reloc(pp_context->sampler_state_table.bo,
1904 I915_GEM_DOMAIN_RENDER,
1907 sizeof(*sampler_8x8) * index + offsetof(struct i965_sampler_8x8, dw1),
1908 pp_context->sampler_state_table.bo_8x8);
1910 /* sample_8x8 UV index 2 */
1912 memset(&sampler_8x8[index], 0, sizeof(*sampler_8x8));
1913 sampler_8x8[index].dw0.avs_filter_type = AVS_FILTER_ADAPTIVE_8_TAP;
1914 sampler_8x8[index].dw0.ief_bypass = 1;
1915 sampler_8x8[index].dw0.ief_filter_type = IEF_FILTER_DETAIL;
1916 sampler_8x8[index].dw0.ief_filter_size = IEF_FILTER_SIZE_5X5;
1917 sampler_8x8[index].dw1.sampler_8x8_state_pointer = pp_context->sampler_state_table.bo_8x8->offset >> 5;
1918 sampler_8x8[index].dw2.global_noise_estimation = 22;
1919 sampler_8x8[index].dw2.strong_edge_threshold = 8;
1920 sampler_8x8[index].dw2.weak_edge_threshold = 1;
1921 sampler_8x8[index].dw3.strong_edge_weight = 7;
1922 sampler_8x8[index].dw3.regular_weight = 2;
1923 sampler_8x8[index].dw3.non_edge_weight = 0;
1924 sampler_8x8[index].dw3.gain_factor = 40;
1925 sampler_8x8[index].dw4.steepness_boost = 0;
1926 sampler_8x8[index].dw4.steepness_threshold = 0;
1927 sampler_8x8[index].dw4.mr_boost = 0;
1928 sampler_8x8[index].dw4.mr_threshold = 5;
1929 sampler_8x8[index].dw5.pwl1_point_1 = 4;
1930 sampler_8x8[index].dw5.pwl1_point_2 = 12;
1931 sampler_8x8[index].dw5.pwl1_point_3 = 16;
1932 sampler_8x8[index].dw5.pwl1_point_4 = 26;
1933 sampler_8x8[index].dw6.pwl1_point_5 = 40;
1934 sampler_8x8[index].dw6.pwl1_point_6 = 160;
1935 sampler_8x8[index].dw6.pwl1_r3_bias_0 = 127;
1936 sampler_8x8[index].dw6.pwl1_r3_bias_1 = 98;
1937 sampler_8x8[index].dw7.pwl1_r3_bias_2 = 88;
1938 sampler_8x8[index].dw7.pwl1_r3_bias_3 = 64;
1939 sampler_8x8[index].dw7.pwl1_r3_bias_4 = 44;
1940 sampler_8x8[index].dw7.pwl1_r3_bias_5 = 0;
1941 sampler_8x8[index].dw8.pwl1_r3_bias_6 = 0;
1942 sampler_8x8[index].dw8.pwl1_r5_bias_0 = 3;
1943 sampler_8x8[index].dw8.pwl1_r5_bias_1 = 32;
1944 sampler_8x8[index].dw8.pwl1_r5_bias_2 = 32;
1945 sampler_8x8[index].dw9.pwl1_r5_bias_3 = 58;
1946 sampler_8x8[index].dw9.pwl1_r5_bias_4 = 100;
1947 sampler_8x8[index].dw9.pwl1_r5_bias_5 = 108;
1948 sampler_8x8[index].dw9.pwl1_r5_bias_6 = 88;
1949 sampler_8x8[index].dw10.pwl1_r3_slope_0 = -116;
1950 sampler_8x8[index].dw10.pwl1_r3_slope_1 = -20;
1951 sampler_8x8[index].dw10.pwl1_r3_slope_2 = -96;
1952 sampler_8x8[index].dw10.pwl1_r3_slope_3 = -32;
1953 sampler_8x8[index].dw11.pwl1_r3_slope_4 = -50;
1954 sampler_8x8[index].dw11.pwl1_r3_slope_5 = 0;
1955 sampler_8x8[index].dw11.pwl1_r3_slope_6 = 0;
1956 sampler_8x8[index].dw11.pwl1_r5_slope_0 = 116;
1957 sampler_8x8[index].dw12.pwl1_r5_slope_1 = 0;
1958 sampler_8x8[index].dw12.pwl1_r5_slope_2 = 114;
1959 sampler_8x8[index].dw12.pwl1_r5_slope_3 = 67;
1960 sampler_8x8[index].dw12.pwl1_r5_slope_4 = 9;
1961 sampler_8x8[index].dw13.pwl1_r5_slope_5 = -3;
1962 sampler_8x8[index].dw13.pwl1_r5_slope_6 = -15;
1963 sampler_8x8[index].dw13.limiter_boost = 0;
1964 sampler_8x8[index].dw13.minimum_limiter = 10;
1965 sampler_8x8[index].dw13.maximum_limiter = 11;
1966 sampler_8x8[index].dw14.clip_limiter = 130;
1967 dri_bo_emit_reloc(pp_context->sampler_state_table.bo,
1968 I915_GEM_DOMAIN_RENDER,
1971 sizeof(*sampler_8x8) * index + offsetof(struct i965_sampler_8x8, dw1),
1972 pp_context->sampler_state_table.bo_8x8);
1974 dri_bo_unmap(pp_context->sampler_state_table.bo);
1976 /* private function & data */
1977 pp_context->pp_x_steps = pp_avs_x_steps;
1978 pp_context->pp_y_steps = pp_avs_y_steps;
1979 pp_context->pp_set_block_parameter = pp_avs_set_block_parameter;
1981 pp_avs_context->dest_x = dst_rect->x;
1982 pp_avs_context->dest_y = dst_rect->y;
1983 pp_avs_context->dest_w = ALIGN(dst_rect->width, 16);
1984 pp_avs_context->dest_h = ALIGN(dst_rect->height, 16);
1985 pp_avs_context->src_normalized_x = (float)src_rect->x / in_w;
1986 pp_avs_context->src_normalized_y = (float)src_rect->y / in_h;
1987 pp_avs_context->src_w = src_rect->width;
1988 pp_avs_context->src_h = src_rect->height;
1990 pp_static_parameter->grf4.r4_2.avs.nlas = nlas;
1991 pp_static_parameter->grf1.r1_6.normalized_video_y_scaling_step = (float) src_rect->height / in_h / dst_rect->height;
1993 pp_inline_parameter->grf5.normalized_video_x_scaling_step = (float) src_rect->width / in_w / dst_rect->width;
1994 pp_inline_parameter->grf5.block_count_x = 1; /* M x 1 */
1995 pp_inline_parameter->grf5.number_blocks = pp_avs_context->dest_h / 8;
1996 pp_inline_parameter->grf5.block_vertical_mask = 0xff;
1997 pp_inline_parameter->grf5.block_horizontal_mask = 0xffff;
1998 pp_inline_parameter->grf6.video_step_delta = 0.0;
2000 dst_surface->flags = src_surface->flags;
2002 return VA_STATUS_SUCCESS;
2006 pp_nv12_avs_initialize_nlas(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2007 const struct i965_surface *src_surface,
2008 const VARectangle *src_rect,
2009 struct i965_surface *dst_surface,
2010 const VARectangle *dst_rect,
2013 return pp_nv12_avs_initialize(ctx, pp_context,
2023 gen6_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2024 const struct i965_surface *src_surface,
2025 const VARectangle *src_rect,
2026 struct i965_surface *dst_surface,
2027 const VARectangle *dst_rect,
2030 return pp_nv12_avs_initialize(ctx, pp_context,
2040 gen7_pp_avs_x_steps(void *private_context)
2042 struct pp_avs_context *pp_avs_context = private_context;
2044 return pp_avs_context->dest_w / 16;
2048 gen7_pp_avs_y_steps(void *private_context)
2050 struct pp_avs_context *pp_avs_context = private_context;
2052 return pp_avs_context->dest_h / 16;
2056 gen7_pp_avs_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
2058 struct pp_avs_context *pp_avs_context = (struct pp_avs_context *)&pp_context->private_context;
2059 struct gen7_pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2061 pp_inline_parameter->grf7.destination_block_horizontal_origin = x * 16 + pp_avs_context->dest_x;
2062 pp_inline_parameter->grf7.destination_block_vertical_origin = y * 16 + pp_avs_context->dest_y;
2063 pp_inline_parameter->grf7.constant_0 = 0xffffffff;
2064 pp_inline_parameter->grf7.sampler_load_main_video_x_scaling_step = 1.0 / pp_avs_context->src_w;
2070 gen7_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2071 const struct i965_surface *src_surface,
2072 const VARectangle *src_rect,
2073 struct i965_surface *dst_surface,
2074 const VARectangle *dst_rect,
2077 struct pp_avs_context *pp_avs_context = (struct pp_avs_context *)&pp_context->private_context;
2078 struct gen7_pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
2079 struct gen7_sampler_8x8 *sampler_8x8;
2080 struct i965_sampler_8x8_state *sampler_8x8_state;
2082 int width[3], height[3], pitch[3], offset[3];
2084 /* source surface */
2085 gen7_pp_set_media_rw_message_surface(ctx, pp_context, src_surface, 0, 0,
2086 width, height, pitch, offset);
2088 /* destination surface */
2089 gen7_pp_set_media_rw_message_surface(ctx, pp_context, dst_surface, 24, 1,
2090 width, height, pitch, offset);
2092 /* sampler 8x8 state */
2093 dri_bo_map(pp_context->sampler_state_table.bo_8x8, True);
2094 assert(pp_context->sampler_state_table.bo_8x8->virtual);
2095 assert(sizeof(*sampler_8x8_state) == sizeof(int) * 138);
2096 sampler_8x8_state = pp_context->sampler_state_table.bo_8x8->virtual;
2097 memset(sampler_8x8_state, 0, sizeof(*sampler_8x8_state));
2099 for (i = 0; i < 17; i++) {
2100 /* for Y channel, currently ignore */
2101 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c0 = 0x0;
2102 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c1 = 0x0;
2103 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c2 = 0x0;
2104 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c3 = 0x0;
2105 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c4 = 0x0;
2106 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c5 = 0x0;
2107 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c6 = 0x0;
2108 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c7 = 0x0;
2109 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c0 = 0x0;
2110 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c1 = 0x0;
2111 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c2 = 0x0;
2112 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c3 = 0x0;
2113 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c4 = 0x0;
2114 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c5 = 0x0;
2115 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c6 = 0x0;
2116 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c7 = 0x0;
2117 /* for U/V channel, 0.25 */
2118 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c0 = 0x0;
2119 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c1 = 0x0;
2120 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c2 = 0x10;
2121 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c3 = 0x10;
2122 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c4 = 0x10;
2123 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c5 = 0x10;
2124 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c6 = 0x0;
2125 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c7 = 0x0;
2126 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c0 = 0x0;
2127 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c1 = 0x0;
2128 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c2 = 0x10;
2129 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c3 = 0x10;
2130 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c4 = 0x10;
2131 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c5 = 0x10;
2132 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c6 = 0x0;
2133 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c7 = 0x0;
2136 sampler_8x8_state->dw136.default_sharpness_level = 0;
2137 sampler_8x8_state->dw137.adaptive_filter_for_all_channel = 1;
2138 sampler_8x8_state->dw137.bypass_y_adaptive_filtering = 1;
2139 sampler_8x8_state->dw137.bypass_x_adaptive_filtering = 1;
2140 dri_bo_unmap(pp_context->sampler_state_table.bo_8x8);
2143 dri_bo_map(pp_context->sampler_state_table.bo, True);
2144 assert(pp_context->sampler_state_table.bo->virtual);
2145 assert(sizeof(*sampler_8x8) == sizeof(int) * 4);
2146 sampler_8x8 = pp_context->sampler_state_table.bo->virtual;
2148 /* sample_8x8 Y index 4 */
2150 memset(&sampler_8x8[index], 0, sizeof(*sampler_8x8));
2151 sampler_8x8[index].dw0.global_noise_estimation = 255;
2152 sampler_8x8[index].dw0.ief_bypass = 1;
2154 sampler_8x8[index].dw1.sampler_8x8_state_pointer = pp_context->sampler_state_table.bo_8x8->offset >> 5;
2156 sampler_8x8[index].dw2.weak_edge_threshold = 1;
2157 sampler_8x8[index].dw2.strong_edge_threshold = 8;
2158 sampler_8x8[index].dw2.r5x_coefficient = 9;
2159 sampler_8x8[index].dw2.r5cx_coefficient = 8;
2160 sampler_8x8[index].dw2.r5c_coefficient = 3;
2162 sampler_8x8[index].dw3.r3x_coefficient = 27;
2163 sampler_8x8[index].dw3.r3c_coefficient = 5;
2164 sampler_8x8[index].dw3.gain_factor = 40;
2165 sampler_8x8[index].dw3.non_edge_weight = 1;
2166 sampler_8x8[index].dw3.regular_weight = 2;
2167 sampler_8x8[index].dw3.strong_edge_weight = 7;
2168 sampler_8x8[index].dw3.ief4_smooth_enable = 0;
2170 dri_bo_emit_reloc(pp_context->sampler_state_table.bo,
2171 I915_GEM_DOMAIN_RENDER,
2174 sizeof(*sampler_8x8) * index + offsetof(struct i965_sampler_8x8, dw1),
2175 pp_context->sampler_state_table.bo_8x8);
2177 /* sample_8x8 UV index 8 */
2179 memset(&sampler_8x8[index], 0, sizeof(*sampler_8x8));
2180 sampler_8x8[index].dw0.disable_8x8_filter = 0;
2181 sampler_8x8[index].dw0.global_noise_estimation = 255;
2182 sampler_8x8[index].dw0.ief_bypass = 1;
2183 sampler_8x8[index].dw1.sampler_8x8_state_pointer = pp_context->sampler_state_table.bo_8x8->offset >> 5;
2184 sampler_8x8[index].dw2.weak_edge_threshold = 1;
2185 sampler_8x8[index].dw2.strong_edge_threshold = 8;
2186 sampler_8x8[index].dw2.r5x_coefficient = 9;
2187 sampler_8x8[index].dw2.r5cx_coefficient = 8;
2188 sampler_8x8[index].dw2.r5c_coefficient = 3;
2189 sampler_8x8[index].dw3.r3x_coefficient = 27;
2190 sampler_8x8[index].dw3.r3c_coefficient = 5;
2191 sampler_8x8[index].dw3.gain_factor = 40;
2192 sampler_8x8[index].dw3.non_edge_weight = 1;
2193 sampler_8x8[index].dw3.regular_weight = 2;
2194 sampler_8x8[index].dw3.strong_edge_weight = 7;
2195 sampler_8x8[index].dw3.ief4_smooth_enable = 0;
2197 dri_bo_emit_reloc(pp_context->sampler_state_table.bo,
2198 I915_GEM_DOMAIN_RENDER,
2201 sizeof(*sampler_8x8) * index + offsetof(struct i965_sampler_8x8, dw1),
2202 pp_context->sampler_state_table.bo_8x8);
2204 /* sampler_8x8 V, index 12 */
2206 memset(&sampler_8x8[index], 0, sizeof(*sampler_8x8));
2207 sampler_8x8[index].dw0.disable_8x8_filter = 0;
2208 sampler_8x8[index].dw0.global_noise_estimation = 255;
2209 sampler_8x8[index].dw0.ief_bypass = 1;
2210 sampler_8x8[index].dw1.sampler_8x8_state_pointer = pp_context->sampler_state_table.bo_8x8->offset >> 5;
2211 sampler_8x8[index].dw2.weak_edge_threshold = 1;
2212 sampler_8x8[index].dw2.strong_edge_threshold = 8;
2213 sampler_8x8[index].dw2.r5x_coefficient = 9;
2214 sampler_8x8[index].dw2.r5cx_coefficient = 8;
2215 sampler_8x8[index].dw2.r5c_coefficient = 3;
2216 sampler_8x8[index].dw3.r3x_coefficient = 27;
2217 sampler_8x8[index].dw3.r3c_coefficient = 5;
2218 sampler_8x8[index].dw3.gain_factor = 40;
2219 sampler_8x8[index].dw3.non_edge_weight = 1;
2220 sampler_8x8[index].dw3.regular_weight = 2;
2221 sampler_8x8[index].dw3.strong_edge_weight = 7;
2222 sampler_8x8[index].dw3.ief4_smooth_enable = 0;
2224 dri_bo_emit_reloc(pp_context->sampler_state_table.bo,
2225 I915_GEM_DOMAIN_RENDER,
2228 sizeof(*sampler_8x8) * index + offsetof(struct i965_sampler_8x8, dw1),
2229 pp_context->sampler_state_table.bo_8x8);
2231 dri_bo_unmap(pp_context->sampler_state_table.bo);
2233 /* private function & data */
2234 pp_context->pp_x_steps = gen7_pp_avs_x_steps;
2235 pp_context->pp_y_steps = gen7_pp_avs_y_steps;
2236 pp_context->pp_set_block_parameter = gen7_pp_avs_set_block_parameter;
2238 pp_avs_context->dest_x = dst_rect->x;
2239 pp_avs_context->dest_y = dst_rect->y;
2240 pp_avs_context->dest_w = ALIGN(dst_rect->width, 16);
2241 pp_avs_context->dest_h = ALIGN(dst_rect->height, 16);
2242 pp_avs_context->src_w = src_rect->width;
2243 pp_avs_context->src_h = src_rect->height;
2245 int dw = (pp_avs_context->src_w - 1) / 16 + 1;
2246 dw = MAX(dw, pp_avs_context->dest_w);
2248 pp_static_parameter->grf1.pointer_to_inline_parameter = 7;
2249 pp_static_parameter->grf3.sampler_load_horizontal_scaling_step_ratio = (float) pp_avs_context->src_w / dw;
2250 pp_static_parameter->grf4.sampler_load_vertical_scaling_step = (float) 1.0 / pp_avs_context->dest_h;
2251 pp_static_parameter->grf5.sampler_load_vertical_frame_origin = -(float)pp_avs_context->dest_y / pp_avs_context->dest_h;
2252 pp_static_parameter->grf6.sampler_load_horizontal_frame_origin = -(float)pp_avs_context->dest_x / dw;
2254 dst_surface->flags = src_surface->flags;
2256 return VA_STATUS_SUCCESS;
2260 pp_dndi_x_steps(void *private_context)
2266 pp_dndi_y_steps(void *private_context)
2268 struct pp_dndi_context *pp_dndi_context = private_context;
2270 return pp_dndi_context->dest_h / 4;
2274 pp_dndi_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
2276 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2278 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16;
2279 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 4;
2285 pp_nv12_dndi_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2286 const struct i965_surface *src_surface,
2287 const VARectangle *src_rect,
2288 struct i965_surface *dst_surface,
2289 const VARectangle *dst_rect,
2292 struct i965_driver_data *i965 = i965_driver_data(ctx);
2293 struct pp_dndi_context *pp_dndi_context = (struct pp_dndi_context *)&pp_context->private_context;
2294 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2295 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
2296 struct object_surface *obj_surface;
2297 struct i965_sampler_dndi *sampler_dndi;
2301 int dndi_top_first = 1;
2303 if (src_surface->flags == I965_SURFACE_FLAG_FRAME)
2304 return VA_STATUS_ERROR_FLAG_NOT_SUPPORTED;
2306 if (src_surface->flags == I965_SURFACE_FLAG_TOP_FIELD_FIRST)
2312 obj_surface = SURFACE(src_surface->id);
2313 orig_w = obj_surface->orig_width;
2314 orig_h = obj_surface->orig_height;
2315 w = obj_surface->width;
2316 h = obj_surface->height;
2318 if (pp_context->stmm.bo == NULL) {
2319 pp_context->stmm.bo = dri_bo_alloc(i965->intel.bufmgr,
2323 assert(pp_context->stmm.bo);
2326 /* source UV surface index 2 */
2327 i965_pp_set_surface_state(ctx, pp_context,
2328 obj_surface->bo, w * h,
2329 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2332 /* source YUV surface index 4 */
2333 i965_pp_set_surface2_state(ctx, pp_context,
2337 SURFACE_FORMAT_PLANAR_420_8, 1,
2340 /* source STMM surface index 20 */
2341 i965_pp_set_surface_state(ctx, pp_context,
2342 pp_context->stmm.bo, 0,
2343 orig_w, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2346 /* destination surface */
2347 obj_surface = SURFACE(dst_surface->id);
2348 orig_w = obj_surface->orig_width;
2349 orig_h = obj_surface->orig_height;
2350 w = obj_surface->width;
2351 h = obj_surface->height;
2353 /* destination Y surface index 7 */
2354 i965_pp_set_surface_state(ctx, pp_context,
2356 orig_w / 4, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2359 /* destination UV surface index 8 */
2360 i965_pp_set_surface_state(ctx, pp_context,
2361 obj_surface->bo, w * h,
2362 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2365 dri_bo_map(pp_context->sampler_state_table.bo, True);
2366 assert(pp_context->sampler_state_table.bo->virtual);
2367 assert(sizeof(*sampler_dndi) == sizeof(int) * 8);
2368 sampler_dndi = pp_context->sampler_state_table.bo->virtual;
2370 /* sample dndi index 1 */
2372 sampler_dndi[index].dw0.denoise_asd_threshold = 0;
2373 sampler_dndi[index].dw0.denoise_history_delta = 8; // 0-15, default is 8
2374 sampler_dndi[index].dw0.denoise_maximum_history = 128; // 128-240
2375 sampler_dndi[index].dw0.denoise_stad_threshold = 0;
2377 sampler_dndi[index].dw1.denoise_threshold_for_sum_of_complexity_measure = 64;
2378 sampler_dndi[index].dw1.denoise_moving_pixel_threshold = 4;
2379 sampler_dndi[index].dw1.stmm_c2 = 1;
2380 sampler_dndi[index].dw1.low_temporal_difference_threshold = 8;
2381 sampler_dndi[index].dw1.temporal_difference_threshold = 16;
2383 sampler_dndi[index].dw2.block_noise_estimate_noise_threshold = 15; // 0-31
2384 sampler_dndi[index].dw2.block_noise_estimate_edge_threshold = 7; // 0-15
2385 sampler_dndi[index].dw2.denoise_edge_threshold = 7; // 0-15
2386 sampler_dndi[index].dw2.good_neighbor_threshold = 4; // 0-63
2388 sampler_dndi[index].dw3.maximum_stmm = 128;
2389 sampler_dndi[index].dw3.multipler_for_vecm = 2;
2390 sampler_dndi[index].dw3.blending_constant_across_time_for_small_values_of_stmm = 0;
2391 sampler_dndi[index].dw3.blending_constant_across_time_for_large_values_of_stmm = 64;
2392 sampler_dndi[index].dw3.stmm_blending_constant_select = 0;
2394 sampler_dndi[index].dw4.sdi_delta = 8;
2395 sampler_dndi[index].dw4.sdi_threshold = 128;
2396 sampler_dndi[index].dw4.stmm_output_shift = 7; // stmm_max - stmm_min = 2 ^ stmm_output_shift
2397 sampler_dndi[index].dw4.stmm_shift_up = 0;
2398 sampler_dndi[index].dw4.stmm_shift_down = 0;
2399 sampler_dndi[index].dw4.minimum_stmm = 0;
2401 sampler_dndi[index].dw5.fmd_temporal_difference_threshold = 8;
2402 sampler_dndi[index].dw5.sdi_fallback_mode_2_constant = 32;
2403 sampler_dndi[index].dw5.sdi_fallback_mode_1_t2_constant = 64;
2404 sampler_dndi[index].dw5.sdi_fallback_mode_1_t1_constant = 32;
2406 sampler_dndi[index].dw6.dn_enable = 1;
2407 sampler_dndi[index].dw6.di_enable = 1;
2408 sampler_dndi[index].dw6.di_partial = 0;
2409 sampler_dndi[index].dw6.dndi_top_first = dndi_top_first;
2410 sampler_dndi[index].dw6.dndi_stream_id = 0;
2411 sampler_dndi[index].dw6.dndi_first_frame = 1;
2412 sampler_dndi[index].dw6.progressive_dn = 0;
2413 sampler_dndi[index].dw6.fmd_tear_threshold = 63;
2414 sampler_dndi[index].dw6.fmd2_vertical_difference_threshold = 32;
2415 sampler_dndi[index].dw6.fmd1_vertical_difference_threshold = 32;
2417 sampler_dndi[index].dw7.fmd_for_1st_field_of_current_frame = 0;
2418 sampler_dndi[index].dw7.fmd_for_2nd_field_of_previous_frame = 0;
2419 sampler_dndi[index].dw7.vdi_walker_enable = 0;
2420 sampler_dndi[index].dw7.column_width_minus1 = 0;
2422 dri_bo_unmap(pp_context->sampler_state_table.bo);
2424 /* private function & data */
2425 pp_context->pp_x_steps = pp_dndi_x_steps;
2426 pp_context->pp_y_steps = pp_dndi_y_steps;
2427 pp_context->pp_set_block_parameter = pp_dndi_set_block_parameter;
2429 pp_static_parameter->grf1.statistics_surface_picth = w / 2;
2430 pp_static_parameter->grf1.r1_6.di.top_field_first = dndi_top_first;
2431 pp_static_parameter->grf4.r4_2.di.motion_history_coefficient_m2 = 0;
2432 pp_static_parameter->grf4.r4_2.di.motion_history_coefficient_m1 = 0;
2434 pp_inline_parameter->grf5.block_count_x = w / 16; /* 1 x N */
2435 pp_inline_parameter->grf5.number_blocks = w / 16;
2436 pp_inline_parameter->grf5.block_vertical_mask = 0xff;
2437 pp_inline_parameter->grf5.block_horizontal_mask = 0xffff;
2439 pp_dndi_context->dest_w = w;
2440 pp_dndi_context->dest_h = h;
2442 dst_surface->flags = I965_SURFACE_FLAG_FRAME;
2444 return VA_STATUS_SUCCESS;
2448 pp_dn_x_steps(void *private_context)
2454 pp_dn_y_steps(void *private_context)
2456 struct pp_dn_context *pp_dn_context = private_context;
2458 return pp_dn_context->dest_h / 8;
2462 pp_dn_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
2464 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2466 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16;
2467 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 8;
2473 pp_nv12_dn_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2474 const struct i965_surface *src_surface,
2475 const VARectangle *src_rect,
2476 struct i965_surface *dst_surface,
2477 const VARectangle *dst_rect,
2480 struct i965_driver_data *i965 = i965_driver_data(ctx);
2481 struct pp_dn_context *pp_dn_context = (struct pp_dn_context *)&pp_context->private_context;
2482 struct object_surface *obj_surface;
2483 struct i965_sampler_dndi *sampler_dndi;
2484 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
2485 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2486 VAProcFilterParameterBuffer *dn_filter_param = filter_param; /* FIXME: parameter */
2490 int dn_strength = 15;
2491 int dndi_top_first = 1;
2492 int dn_progressive = 0;
2494 if (src_surface->flags == I965_SURFACE_FLAG_FRAME) {
2497 } else if (src_surface->flags == I965_SURFACE_FLAG_TOP_FIELD_FIRST) {
2505 if (dn_filter_param) {
2506 float value = dn_filter_param->value;
2514 dn_strength = (int)(value * 31.0F);
2518 obj_surface = SURFACE(src_surface->id);
2519 orig_w = obj_surface->orig_width;
2520 orig_h = obj_surface->orig_height;
2521 w = obj_surface->width;
2522 h = obj_surface->height;
2524 if (pp_context->stmm.bo == NULL) {
2525 pp_context->stmm.bo = dri_bo_alloc(i965->intel.bufmgr,
2529 assert(pp_context->stmm.bo);
2532 /* source UV surface index 2 */
2533 i965_pp_set_surface_state(ctx, pp_context,
2534 obj_surface->bo, w * h,
2535 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2538 /* source YUV surface index 4 */
2539 i965_pp_set_surface2_state(ctx, pp_context,
2543 SURFACE_FORMAT_PLANAR_420_8, 1,
2546 /* source STMM surface index 20 */
2547 i965_pp_set_surface_state(ctx, pp_context,
2548 pp_context->stmm.bo, 0,
2549 orig_w, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2552 /* destination surface */
2553 obj_surface = SURFACE(dst_surface->id);
2554 orig_w = obj_surface->orig_width;
2555 orig_h = obj_surface->orig_height;
2556 w = obj_surface->width;
2557 h = obj_surface->height;
2559 /* destination Y surface index 7 */
2560 i965_pp_set_surface_state(ctx, pp_context,
2562 orig_w / 4, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2565 /* destination UV surface index 8 */
2566 i965_pp_set_surface_state(ctx, pp_context,
2567 obj_surface->bo, w * h,
2568 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2571 dri_bo_map(pp_context->sampler_state_table.bo, True);
2572 assert(pp_context->sampler_state_table.bo->virtual);
2573 assert(sizeof(*sampler_dndi) == sizeof(int) * 8);
2574 sampler_dndi = pp_context->sampler_state_table.bo->virtual;
2576 /* sample dndi index 1 */
2578 sampler_dndi[index].dw0.denoise_asd_threshold = 0;
2579 sampler_dndi[index].dw0.denoise_history_delta = 8; // 0-15, default is 8
2580 sampler_dndi[index].dw0.denoise_maximum_history = 128; // 128-240
2581 sampler_dndi[index].dw0.denoise_stad_threshold = 0;
2583 sampler_dndi[index].dw1.denoise_threshold_for_sum_of_complexity_measure = 64;
2584 sampler_dndi[index].dw1.denoise_moving_pixel_threshold = 0;
2585 sampler_dndi[index].dw1.stmm_c2 = 0;
2586 sampler_dndi[index].dw1.low_temporal_difference_threshold = 8;
2587 sampler_dndi[index].dw1.temporal_difference_threshold = 16;
2589 sampler_dndi[index].dw2.block_noise_estimate_noise_threshold = dn_strength; // 0-31
2590 sampler_dndi[index].dw2.block_noise_estimate_edge_threshold = 7; // 0-15
2591 sampler_dndi[index].dw2.denoise_edge_threshold = 7; // 0-15
2592 sampler_dndi[index].dw2.good_neighbor_threshold = 7; // 0-63
2594 sampler_dndi[index].dw3.maximum_stmm = 128;
2595 sampler_dndi[index].dw3.multipler_for_vecm = 2;
2596 sampler_dndi[index].dw3.blending_constant_across_time_for_small_values_of_stmm = 0;
2597 sampler_dndi[index].dw3.blending_constant_across_time_for_large_values_of_stmm = 64;
2598 sampler_dndi[index].dw3.stmm_blending_constant_select = 0;
2600 sampler_dndi[index].dw4.sdi_delta = 8;
2601 sampler_dndi[index].dw4.sdi_threshold = 128;
2602 sampler_dndi[index].dw4.stmm_output_shift = 7; // stmm_max - stmm_min = 2 ^ stmm_output_shift
2603 sampler_dndi[index].dw4.stmm_shift_up = 0;
2604 sampler_dndi[index].dw4.stmm_shift_down = 0;
2605 sampler_dndi[index].dw4.minimum_stmm = 0;
2607 sampler_dndi[index].dw5.fmd_temporal_difference_threshold = 0;
2608 sampler_dndi[index].dw5.sdi_fallback_mode_2_constant = 0;
2609 sampler_dndi[index].dw5.sdi_fallback_mode_1_t2_constant = 0;
2610 sampler_dndi[index].dw5.sdi_fallback_mode_1_t1_constant = 0;
2612 sampler_dndi[index].dw6.dn_enable = 1;
2613 sampler_dndi[index].dw6.di_enable = 0;
2614 sampler_dndi[index].dw6.di_partial = 0;
2615 sampler_dndi[index].dw6.dndi_top_first = dndi_top_first;
2616 sampler_dndi[index].dw6.dndi_stream_id = 1;
2617 sampler_dndi[index].dw6.dndi_first_frame = 1;
2618 sampler_dndi[index].dw6.progressive_dn = dn_progressive;
2619 sampler_dndi[index].dw6.fmd_tear_threshold = 32;
2620 sampler_dndi[index].dw6.fmd2_vertical_difference_threshold = 32;
2621 sampler_dndi[index].dw6.fmd1_vertical_difference_threshold = 32;
2623 sampler_dndi[index].dw7.fmd_for_1st_field_of_current_frame = 2;
2624 sampler_dndi[index].dw7.fmd_for_2nd_field_of_previous_frame = 1;
2625 sampler_dndi[index].dw7.vdi_walker_enable = 0;
2626 sampler_dndi[index].dw7.column_width_minus1 = w / 16;
2628 dri_bo_unmap(pp_context->sampler_state_table.bo);
2630 /* private function & data */
2631 pp_context->pp_x_steps = pp_dn_x_steps;
2632 pp_context->pp_y_steps = pp_dn_y_steps;
2633 pp_context->pp_set_block_parameter = pp_dn_set_block_parameter;
2635 pp_static_parameter->grf1.statistics_surface_picth = w / 2;
2636 pp_static_parameter->grf1.r1_6.di.top_field_first = 0;
2637 pp_static_parameter->grf4.r4_2.di.motion_history_coefficient_m2 = 64;
2638 pp_static_parameter->grf4.r4_2.di.motion_history_coefficient_m1 = 192;
2640 pp_inline_parameter->grf5.block_count_x = w / 16; /* 1 x N */
2641 pp_inline_parameter->grf5.number_blocks = w / 16;
2642 pp_inline_parameter->grf5.block_vertical_mask = 0xff;
2643 pp_inline_parameter->grf5.block_horizontal_mask = 0xffff;
2645 pp_dn_context->dest_w = w;
2646 pp_dn_context->dest_h = h;
2648 dst_surface->flags = src_surface->flags;
2650 return VA_STATUS_SUCCESS;
2654 gen7_pp_dndi_x_steps(void *private_context)
2656 struct pp_dndi_context *pp_dndi_context = private_context;
2658 return pp_dndi_context->dest_w / 16;
2662 gen7_pp_dndi_y_steps(void *private_context)
2664 struct pp_dndi_context *pp_dndi_context = private_context;
2666 return pp_dndi_context->dest_h / 4;
2670 gen7_pp_dndi_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
2672 struct gen7_pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2674 pp_inline_parameter->grf7.destination_block_horizontal_origin = x * 16;
2675 pp_inline_parameter->grf7.destination_block_vertical_origin = y * 4;
2681 gen7_pp_nv12_dndi_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2682 const struct i965_surface *src_surface,
2683 const VARectangle *src_rect,
2684 struct i965_surface *dst_surface,
2685 const VARectangle *dst_rect,
2688 struct i965_driver_data *i965 = i965_driver_data(ctx);
2689 struct pp_dndi_context *pp_dndi_context = (struct pp_dndi_context *)&pp_context->private_context;
2690 struct gen7_pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
2691 struct object_surface *obj_surface;
2692 struct gen7_sampler_dndi *sampler_dndi;
2696 int dndi_top_first = 1;
2698 if (src_surface->flags == I965_SURFACE_FLAG_FRAME)
2699 return VA_STATUS_ERROR_FLAG_NOT_SUPPORTED;
2701 if (src_surface->flags == I965_SURFACE_FLAG_TOP_FIELD_FIRST)
2707 obj_surface = SURFACE(src_surface->id);
2708 orig_w = obj_surface->orig_width;
2709 orig_h = obj_surface->orig_height;
2710 w = obj_surface->width;
2711 h = obj_surface->height;
2713 if (pp_context->stmm.bo == NULL) {
2714 pp_context->stmm.bo = dri_bo_alloc(i965->intel.bufmgr,
2718 assert(pp_context->stmm.bo);
2721 /* source UV surface index 1 */
2722 gen7_pp_set_surface_state(ctx, pp_context,
2723 obj_surface->bo, w * h,
2724 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2727 /* source YUV surface index 3 */
2728 gen7_pp_set_surface2_state(ctx, pp_context,
2732 SURFACE_FORMAT_PLANAR_420_8, 1,
2735 /* source (temporal reference) YUV surface index 4 */
2736 gen7_pp_set_surface2_state(ctx, pp_context,
2740 SURFACE_FORMAT_PLANAR_420_8, 1,
2743 /* STMM / History Statistics input surface, index 5 */
2744 gen7_pp_set_surface_state(ctx, pp_context,
2745 pp_context->stmm.bo, 0,
2746 orig_w, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2749 /* destination surface */
2750 obj_surface = SURFACE(dst_surface->id);
2751 orig_w = obj_surface->orig_width;
2752 orig_h = obj_surface->orig_height;
2753 w = obj_surface->width;
2754 h = obj_surface->height;
2756 /* destination(Previous frame) Y surface index 27 */
2757 gen7_pp_set_surface_state(ctx, pp_context,
2759 orig_w / 4, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2762 /* destination(Previous frame) UV surface index 28 */
2763 gen7_pp_set_surface_state(ctx, pp_context,
2764 obj_surface->bo, w * h,
2765 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2768 /* destination(Current frame) Y surface index 30 */
2769 gen7_pp_set_surface_state(ctx, pp_context,
2771 orig_w / 4, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2774 /* destination(Current frame) UV surface index 31 */
2775 gen7_pp_set_surface_state(ctx, pp_context,
2776 obj_surface->bo, w * h,
2777 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2780 /* STMM output surface, index 33 */
2781 gen7_pp_set_surface_state(ctx, pp_context,
2782 pp_context->stmm.bo, 0,
2783 orig_w, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2788 dri_bo_map(pp_context->sampler_state_table.bo, True);
2789 assert(pp_context->sampler_state_table.bo->virtual);
2790 assert(sizeof(*sampler_dndi) == sizeof(int) * 8);
2791 sampler_dndi = pp_context->sampler_state_table.bo->virtual;
2793 /* sample dndi index 0 */
2795 sampler_dndi[index].dw0.denoise_asd_threshold = 0;
2796 sampler_dndi[index].dw0.dnmh_delt = 8;
2797 sampler_dndi[index].dw0.vdi_walker_y_stride = 0;
2798 sampler_dndi[index].dw0.vdi_walker_frame_sharing_enable = 0;
2799 sampler_dndi[index].dw0.denoise_maximum_history = 128; // 128-240
2800 sampler_dndi[index].dw0.denoise_stad_threshold = 0;
2802 sampler_dndi[index].dw1.denoise_threshold_for_sum_of_complexity_measure = 64;
2803 sampler_dndi[index].dw1.denoise_moving_pixel_threshold = 0;
2804 sampler_dndi[index].dw1.stmm_c2 = 0;
2805 sampler_dndi[index].dw1.low_temporal_difference_threshold = 8;
2806 sampler_dndi[index].dw1.temporal_difference_threshold = 16;
2808 sampler_dndi[index].dw2.block_noise_estimate_noise_threshold = 15; // 0-31
2809 sampler_dndi[index].dw2.bne_edge_th = 1;
2810 sampler_dndi[index].dw2.smooth_mv_th = 0;
2811 sampler_dndi[index].dw2.sad_tight_th = 5;
2812 sampler_dndi[index].dw2.cat_slope_minus1 = 9;
2813 sampler_dndi[index].dw2.good_neighbor_th = 4;
2815 sampler_dndi[index].dw3.maximum_stmm = 128;
2816 sampler_dndi[index].dw3.multipler_for_vecm = 2;
2817 sampler_dndi[index].dw3.blending_constant_across_time_for_small_values_of_stmm = 0;
2818 sampler_dndi[index].dw3.blending_constant_across_time_for_large_values_of_stmm = 64;
2819 sampler_dndi[index].dw3.stmm_blending_constant_select = 0;
2821 sampler_dndi[index].dw4.sdi_delta = 8;
2822 sampler_dndi[index].dw4.sdi_threshold = 128;
2823 sampler_dndi[index].dw4.stmm_output_shift = 7; // stmm_max - stmm_min = 2 ^ stmm_output_shift
2824 sampler_dndi[index].dw4.stmm_shift_up = 0;
2825 sampler_dndi[index].dw4.stmm_shift_down = 0;
2826 sampler_dndi[index].dw4.minimum_stmm = 0;
2828 sampler_dndi[index].dw5.fmd_temporal_difference_threshold = 0;
2829 sampler_dndi[index].dw5.sdi_fallback_mode_2_constant = 0;
2830 sampler_dndi[index].dw5.sdi_fallback_mode_1_t2_constant = 0;
2831 sampler_dndi[index].dw5.sdi_fallback_mode_1_t1_constant = 0;
2833 sampler_dndi[index].dw6.dn_enable = 0;
2834 sampler_dndi[index].dw6.di_enable = 1;
2835 sampler_dndi[index].dw6.di_partial = 0;
2836 sampler_dndi[index].dw6.dndi_top_first = dndi_top_first;
2837 sampler_dndi[index].dw6.dndi_stream_id = 1;
2838 sampler_dndi[index].dw6.dndi_first_frame = 1;
2839 sampler_dndi[index].dw6.progressive_dn = 0;
2840 sampler_dndi[index].dw6.mcdi_enable = 0;
2841 sampler_dndi[index].dw6.fmd_tear_threshold = 32;
2842 sampler_dndi[index].dw6.cat_th1 = 0;
2843 sampler_dndi[index].dw6.fmd2_vertical_difference_threshold = 32;
2844 sampler_dndi[index].dw6.fmd1_vertical_difference_threshold = 32;
2846 sampler_dndi[index].dw7.sad_tha = 5;
2847 sampler_dndi[index].dw7.sad_thb = 10;
2848 sampler_dndi[index].dw7.fmd_for_1st_field_of_current_frame = 0;
2849 sampler_dndi[index].dw7.mc_pixel_consistency_th = 25;
2850 sampler_dndi[index].dw7.fmd_for_2nd_field_of_previous_frame = 0;
2851 sampler_dndi[index].dw7.vdi_walker_enable = 0;
2852 sampler_dndi[index].dw7.neighborpixel_th = 10;
2853 sampler_dndi[index].dw7.column_width_minus1 = w / 16;
2855 dri_bo_unmap(pp_context->sampler_state_table.bo);
2857 /* private function & data */
2858 pp_context->pp_x_steps = gen7_pp_dndi_x_steps;
2859 pp_context->pp_y_steps = gen7_pp_dndi_y_steps;
2860 pp_context->pp_set_block_parameter = gen7_pp_dndi_set_block_parameter;
2862 pp_static_parameter->grf1.di_statistics_surface_pitch_div2 = w / 2;
2863 pp_static_parameter->grf1.di_statistics_surface_height_div4 = h / 4;
2864 pp_static_parameter->grf1.di_top_field_first = 0;
2865 pp_static_parameter->grf1.pointer_to_inline_parameter = 7;
2867 pp_static_parameter->grf2.di_destination_packed_y_component_offset = 0;
2868 pp_static_parameter->grf2.di_destination_packed_u_component_offset = 1;
2869 pp_static_parameter->grf2.di_destination_packed_v_component_offset = 3;
2871 pp_static_parameter->grf4.di_hoffset_svf_from_dvf = 0;
2872 pp_static_parameter->grf4.di_voffset_svf_from_dvf = 0;
2874 pp_dndi_context->dest_w = w;
2875 pp_dndi_context->dest_h = h;
2877 dst_surface->flags = I965_SURFACE_FLAG_FRAME;
2879 return VA_STATUS_SUCCESS;
2883 gen7_pp_dn_x_steps(void *private_context)
2889 gen7_pp_dn_y_steps(void *private_context)
2891 struct pp_dn_context *pp_dn_context = private_context;
2893 return pp_dn_context->dest_h / 4;
2897 gen7_pp_dn_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
2899 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2901 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16;
2902 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 4;
2908 gen7_pp_nv12_dn_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2909 const struct i965_surface *src_surface,
2910 const VARectangle *src_rect,
2911 struct i965_surface *dst_surface,
2912 const VARectangle *dst_rect,
2915 struct i965_driver_data *i965 = i965_driver_data(ctx);
2916 struct pp_dn_context *pp_dn_context = (struct pp_dn_context *)&pp_context->private_context;
2917 struct gen7_pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
2918 struct object_surface *obj_surface;
2919 struct gen7_sampler_dndi *sampler_dn;
2920 VAProcFilterParameterBuffer *dn_filter_param = filter_param; /* FIXME: parameter */
2924 int dn_strength = 15;
2925 int dndi_top_first = 1;
2926 int dn_progressive = 0;
2928 if (src_surface->flags == I965_SURFACE_FLAG_FRAME) {
2931 } else if (src_surface->flags == I965_SURFACE_FLAG_TOP_FIELD_FIRST) {
2939 if (dn_filter_param) {
2940 float value = dn_filter_param->value;
2948 dn_strength = (int)(value * 31.0F);
2952 obj_surface = SURFACE(src_surface->id);
2953 orig_w = obj_surface->orig_width;
2954 orig_h = obj_surface->orig_height;
2955 w = obj_surface->width;
2956 h = obj_surface->height;
2958 if (pp_context->stmm.bo == NULL) {
2959 pp_context->stmm.bo = dri_bo_alloc(i965->intel.bufmgr,
2963 assert(pp_context->stmm.bo);
2966 /* source UV surface index 1 */
2967 gen7_pp_set_surface_state(ctx, pp_context,
2968 obj_surface->bo, w * h,
2969 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2972 /* source YUV surface index 3 */
2973 gen7_pp_set_surface2_state(ctx, pp_context,
2977 SURFACE_FORMAT_PLANAR_420_8, 1,
2980 /* source STMM surface index 5 */
2981 gen7_pp_set_surface_state(ctx, pp_context,
2982 pp_context->stmm.bo, 0,
2983 orig_w, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2986 /* destination surface */
2987 obj_surface = SURFACE(dst_surface->id);
2988 orig_w = obj_surface->orig_width;
2989 orig_h = obj_surface->orig_height;
2990 w = obj_surface->width;
2991 h = obj_surface->height;
2993 /* destination Y surface index 7 */
2994 gen7_pp_set_surface_state(ctx, pp_context,
2996 orig_w / 4, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2999 /* destination UV surface index 8 */
3000 gen7_pp_set_surface_state(ctx, pp_context,
3001 obj_surface->bo, w * h,
3002 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
3005 dri_bo_map(pp_context->sampler_state_table.bo, True);
3006 assert(pp_context->sampler_state_table.bo->virtual);
3007 assert(sizeof(*sampler_dn) == sizeof(int) * 8);
3008 sampler_dn = pp_context->sampler_state_table.bo->virtual;
3010 /* sample dn index 1 */
3012 sampler_dn[index].dw0.denoise_asd_threshold = 0;
3013 sampler_dn[index].dw0.dnmh_delt = 8;
3014 sampler_dn[index].dw0.vdi_walker_y_stride = 0;
3015 sampler_dn[index].dw0.vdi_walker_frame_sharing_enable = 0;
3016 sampler_dn[index].dw0.denoise_maximum_history = 128; // 128-240
3017 sampler_dn[index].dw0.denoise_stad_threshold = 0;
3019 sampler_dn[index].dw1.denoise_threshold_for_sum_of_complexity_measure = 64;
3020 sampler_dn[index].dw1.denoise_moving_pixel_threshold = 0;
3021 sampler_dn[index].dw1.stmm_c2 = 0;
3022 sampler_dn[index].dw1.low_temporal_difference_threshold = 8;
3023 sampler_dn[index].dw1.temporal_difference_threshold = 16;
3025 sampler_dn[index].dw2.block_noise_estimate_noise_threshold = dn_strength; // 0-31
3026 sampler_dn[index].dw2.bne_edge_th = 1;
3027 sampler_dn[index].dw2.smooth_mv_th = 0;
3028 sampler_dn[index].dw2.sad_tight_th = 5;
3029 sampler_dn[index].dw2.cat_slope_minus1 = 9;
3030 sampler_dn[index].dw2.good_neighbor_th = 4;
3032 sampler_dn[index].dw3.maximum_stmm = 128;
3033 sampler_dn[index].dw3.multipler_for_vecm = 2;
3034 sampler_dn[index].dw3.blending_constant_across_time_for_small_values_of_stmm = 0;
3035 sampler_dn[index].dw3.blending_constant_across_time_for_large_values_of_stmm = 64;
3036 sampler_dn[index].dw3.stmm_blending_constant_select = 0;
3038 sampler_dn[index].dw4.sdi_delta = 8;
3039 sampler_dn[index].dw4.sdi_threshold = 128;
3040 sampler_dn[index].dw4.stmm_output_shift = 7; // stmm_max - stmm_min = 2 ^ stmm_output_shift
3041 sampler_dn[index].dw4.stmm_shift_up = 0;
3042 sampler_dn[index].dw4.stmm_shift_down = 0;
3043 sampler_dn[index].dw4.minimum_stmm = 0;
3045 sampler_dn[index].dw5.fmd_temporal_difference_threshold = 0;
3046 sampler_dn[index].dw5.sdi_fallback_mode_2_constant = 0;
3047 sampler_dn[index].dw5.sdi_fallback_mode_1_t2_constant = 0;
3048 sampler_dn[index].dw5.sdi_fallback_mode_1_t1_constant = 0;
3050 sampler_dn[index].dw6.dn_enable = 1;
3051 sampler_dn[index].dw6.di_enable = 0;
3052 sampler_dn[index].dw6.di_partial = 0;
3053 sampler_dn[index].dw6.dndi_top_first = dndi_top_first;
3054 sampler_dn[index].dw6.dndi_stream_id = 1;
3055 sampler_dn[index].dw6.dndi_first_frame = 1;
3056 sampler_dn[index].dw6.progressive_dn = dn_progressive;
3057 sampler_dn[index].dw6.mcdi_enable = 0;
3058 sampler_dn[index].dw6.fmd_tear_threshold = 32;
3059 sampler_dn[index].dw6.cat_th1 = 0;
3060 sampler_dn[index].dw6.fmd2_vertical_difference_threshold = 32;
3061 sampler_dn[index].dw6.fmd1_vertical_difference_threshold = 32;
3063 sampler_dn[index].dw7.sad_tha = 5;
3064 sampler_dn[index].dw7.sad_thb = 10;
3065 sampler_dn[index].dw7.fmd_for_1st_field_of_current_frame = 2;
3066 sampler_dn[index].dw7.mc_pixel_consistency_th = 25;
3067 sampler_dn[index].dw7.fmd_for_2nd_field_of_previous_frame = 1;
3068 sampler_dn[index].dw7.vdi_walker_enable = 0;
3069 sampler_dn[index].dw7.neighborpixel_th = 10;
3070 sampler_dn[index].dw7.column_width_minus1 = w / 16;
3072 dri_bo_unmap(pp_context->sampler_state_table.bo);
3074 /* private function & data */
3075 pp_context->pp_x_steps = gen7_pp_dn_x_steps;
3076 pp_context->pp_y_steps = gen7_pp_dn_y_steps;
3077 pp_context->pp_set_block_parameter = gen7_pp_dn_set_block_parameter;
3079 pp_static_parameter->grf1.di_statistics_surface_pitch_div2 = w / 2;
3080 pp_static_parameter->grf1.di_statistics_surface_height_div4 = h / 4;
3081 pp_static_parameter->grf1.di_top_field_first = 0;
3082 pp_static_parameter->grf1.pointer_to_inline_parameter = 7;
3084 pp_static_parameter->grf2.di_destination_packed_y_component_offset = 0;
3085 pp_static_parameter->grf2.di_destination_packed_u_component_offset = 1;
3086 pp_static_parameter->grf2.di_destination_packed_v_component_offset = 3;
3088 pp_static_parameter->grf4.di_hoffset_svf_from_dvf = 0;
3089 pp_static_parameter->grf4.di_voffset_svf_from_dvf = 0;
3091 pp_dn_context->dest_w = w;
3092 pp_dn_context->dest_h = h;
3094 dst_surface->flags = src_surface->flags;
3096 return VA_STATUS_SUCCESS;
3099 // update u/v offset when the surface format are packed yuv
3100 static void i965_update_src_surface_uv_offset(
3101 VADriverContextP ctx,
3102 struct i965_post_processing_context *pp_context,
3103 const struct i965_surface *surface)
3105 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
3106 int fourcc = pp_get_surface_fourcc(ctx, surface);
3108 if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
3109 pp_static_parameter->grf1.source_packed_u_offset = 1;
3110 pp_static_parameter->grf1.source_packed_v_offset = 3;
3112 else if (fourcc == VA_FOURCC('U', 'Y', 'V', 'Y')) {
3113 pp_static_parameter->grf1.source_packed_y_offset = 1;
3114 pp_static_parameter->grf1.source_packed_v_offset = 2;
3119 static void i965_update_dst_surface_uv_offset(
3120 VADriverContextP ctx,
3121 struct i965_post_processing_context *pp_context,
3122 const struct i965_surface *surface)
3124 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
3125 int fourcc = pp_get_surface_fourcc(ctx, surface);
3127 if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
3128 pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_u_offset = 1;
3129 pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_v_offset = 3;
3131 else if (fourcc == VA_FOURCC('U', 'Y', 'V', 'Y')) {
3132 pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_y_offset = 1;
3133 pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_v_offset = 2;
3139 ironlake_pp_initialize(
3140 VADriverContextP ctx,
3141 struct i965_post_processing_context *pp_context,
3142 const struct i965_surface *src_surface,
3143 const VARectangle *src_rect,
3144 struct i965_surface *dst_surface,
3145 const VARectangle *dst_rect,
3151 struct i965_driver_data *i965 = i965_driver_data(ctx);
3152 struct pp_module *pp_module;
3154 int static_param_size, inline_param_size;
3156 dri_bo_unreference(pp_context->surface_state_binding_table.bo);
3157 bo = dri_bo_alloc(i965->intel.bufmgr,
3158 "surface state & binding table",
3159 (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_PP_SURFACES,
3162 pp_context->surface_state_binding_table.bo = bo;
3164 dri_bo_unreference(pp_context->curbe.bo);
3165 bo = dri_bo_alloc(i965->intel.bufmgr,
3170 pp_context->curbe.bo = bo;
3172 dri_bo_unreference(pp_context->idrt.bo);
3173 bo = dri_bo_alloc(i965->intel.bufmgr,
3174 "interface discriptor",
3175 sizeof(struct i965_interface_descriptor),
3178 pp_context->idrt.bo = bo;
3179 pp_context->idrt.num_interface_descriptors = 0;
3181 dri_bo_unreference(pp_context->sampler_state_table.bo);
3182 bo = dri_bo_alloc(i965->intel.bufmgr,
3183 "sampler state table",
3187 dri_bo_map(bo, True);
3188 memset(bo->virtual, 0, bo->size);
3190 pp_context->sampler_state_table.bo = bo;
3192 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8);
3193 bo = dri_bo_alloc(i965->intel.bufmgr,
3194 "sampler 8x8 state ",
3198 pp_context->sampler_state_table.bo_8x8 = bo;
3200 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8_uv);
3201 bo = dri_bo_alloc(i965->intel.bufmgr,
3202 "sampler 8x8 state ",
3206 pp_context->sampler_state_table.bo_8x8_uv = bo;
3208 dri_bo_unreference(pp_context->vfe_state.bo);
3209 bo = dri_bo_alloc(i965->intel.bufmgr,
3211 sizeof(struct i965_vfe_state),
3214 pp_context->vfe_state.bo = bo;
3216 if (IS_GEN7(i965->intel.device_id)) {
3217 static_param_size = sizeof(struct gen7_pp_static_parameter);
3218 inline_param_size = sizeof(struct gen7_pp_inline_parameter);
3220 static_param_size = sizeof(struct pp_static_parameter);
3221 inline_param_size = sizeof(struct pp_inline_parameter);
3224 memset(pp_context->pp_static_parameter, 0, static_param_size);
3225 memset(pp_context->pp_inline_parameter, 0, inline_param_size);
3227 // update u/v offset for packed yuv
3228 i965_update_src_surface_uv_offset (ctx, pp_context, src_surface);
3229 i965_update_dst_surface_uv_offset (ctx, pp_context, dst_surface);
3231 assert(pp_index >= PP_NULL && pp_index < NUM_PP_MODULES);
3232 pp_context->current_pp = pp_index;
3233 pp_module = &pp_context->pp_modules[pp_index];
3235 if (pp_module->initialize)
3236 va_status = pp_module->initialize(ctx, pp_context,
3243 va_status = VA_STATUS_ERROR_UNIMPLEMENTED;
3249 ironlake_post_processing(
3250 VADriverContextP ctx,
3251 struct i965_post_processing_context *pp_context,
3252 const struct i965_surface *src_surface,
3253 const VARectangle *src_rect,
3254 struct i965_surface *dst_surface,
3255 const VARectangle *dst_rect,
3262 va_status = ironlake_pp_initialize(ctx, pp_context,
3270 if (va_status == VA_STATUS_SUCCESS) {
3271 ironlake_pp_states_setup(ctx, pp_context);
3272 ironlake_pp_pipeline_setup(ctx, pp_context);
3280 VADriverContextP ctx,
3281 struct i965_post_processing_context *pp_context,
3282 const struct i965_surface *src_surface,
3283 const VARectangle *src_rect,
3284 struct i965_surface *dst_surface,
3285 const VARectangle *dst_rect,
3291 struct i965_driver_data *i965 = i965_driver_data(ctx);
3292 struct pp_module *pp_module;
3294 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
3295 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
3297 dri_bo_unreference(pp_context->surface_state_binding_table.bo);
3298 bo = dri_bo_alloc(i965->intel.bufmgr,
3299 "surface state & binding table",
3300 (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_PP_SURFACES,
3303 pp_context->surface_state_binding_table.bo = bo;
3305 dri_bo_unreference(pp_context->curbe.bo);
3306 bo = dri_bo_alloc(i965->intel.bufmgr,
3311 pp_context->curbe.bo = bo;
3313 dri_bo_unreference(pp_context->idrt.bo);
3314 bo = dri_bo_alloc(i965->intel.bufmgr,
3315 "interface discriptor",
3316 sizeof(struct gen6_interface_descriptor_data),
3319 pp_context->idrt.bo = bo;
3320 pp_context->idrt.num_interface_descriptors = 0;
3322 dri_bo_unreference(pp_context->sampler_state_table.bo);
3323 bo = dri_bo_alloc(i965->intel.bufmgr,
3324 "sampler state table",
3328 dri_bo_map(bo, True);
3329 memset(bo->virtual, 0, bo->size);
3331 pp_context->sampler_state_table.bo = bo;
3333 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8);
3334 bo = dri_bo_alloc(i965->intel.bufmgr,
3335 "sampler 8x8 state ",
3339 pp_context->sampler_state_table.bo_8x8 = bo;
3341 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8_uv);
3342 bo = dri_bo_alloc(i965->intel.bufmgr,
3343 "sampler 8x8 state ",
3347 pp_context->sampler_state_table.bo_8x8_uv = bo;
3349 dri_bo_unreference(pp_context->vfe_state.bo);
3350 bo = dri_bo_alloc(i965->intel.bufmgr,
3352 sizeof(struct i965_vfe_state),
3355 pp_context->vfe_state.bo = bo;
3357 memset(pp_static_parameter, 0, sizeof(*pp_static_parameter));
3358 memset(pp_inline_parameter, 0, sizeof(*pp_inline_parameter));
3360 // update u/v offset for packed yuv
3361 i965_update_src_surface_uv_offset (ctx, pp_context, src_surface);
3362 i965_update_dst_surface_uv_offset (ctx, pp_context, dst_surface);
3364 assert(pp_index >= PP_NULL && pp_index < NUM_PP_MODULES);
3365 pp_context->current_pp = pp_index;
3366 pp_module = &pp_context->pp_modules[pp_index];
3368 if (pp_module->initialize)
3369 va_status = pp_module->initialize(ctx, pp_context,
3376 va_status = VA_STATUS_ERROR_UNIMPLEMENTED;
3382 gen6_pp_interface_descriptor_table(VADriverContextP ctx,
3383 struct i965_post_processing_context *pp_context)
3385 struct i965_driver_data *i965 = i965_driver_data(ctx);
3386 struct gen6_interface_descriptor_data *desc;
3388 int pp_index = pp_context->current_pp;
3390 bo = pp_context->idrt.bo;
3391 dri_bo_map(bo, True);
3392 assert(bo->virtual);
3394 memset(desc, 0, sizeof(*desc));
3395 desc->desc0.kernel_start_pointer =
3396 pp_context->pp_modules[pp_index].kernel.bo->offset >> 6; /* reloc */
3397 desc->desc1.single_program_flow = 1;
3398 desc->desc1.floating_point_mode = FLOATING_POINT_IEEE_754;
3399 desc->desc2.sampler_count = 1; /* 1 - 4 samplers used */
3400 desc->desc2.sampler_state_pointer =
3401 pp_context->sampler_state_table.bo->offset >> 5;
3402 desc->desc3.binding_table_entry_count = 0;
3403 desc->desc3.binding_table_pointer = (BINDING_TABLE_OFFSET >> 5);
3404 desc->desc4.constant_urb_entry_read_offset = 0;
3406 if (IS_GEN7(i965->intel.device_id))
3407 desc->desc4.constant_urb_entry_read_length = 6; /* grf 1-6 */
3409 desc->desc4.constant_urb_entry_read_length = 4; /* grf 1-4 */
3411 dri_bo_emit_reloc(bo,
3412 I915_GEM_DOMAIN_INSTRUCTION, 0,
3414 offsetof(struct gen6_interface_descriptor_data, desc0),
3415 pp_context->pp_modules[pp_index].kernel.bo);
3417 dri_bo_emit_reloc(bo,
3418 I915_GEM_DOMAIN_INSTRUCTION, 0,
3419 desc->desc2.sampler_count << 2,
3420 offsetof(struct gen6_interface_descriptor_data, desc2),
3421 pp_context->sampler_state_table.bo);
3424 pp_context->idrt.num_interface_descriptors++;
3428 gen6_pp_upload_constants(VADriverContextP ctx,
3429 struct i965_post_processing_context *pp_context)
3431 struct i965_driver_data *i965 = i965_driver_data(ctx);
3432 unsigned char *constant_buffer;
3435 assert(sizeof(struct pp_static_parameter) == 128);
3436 assert(sizeof(struct gen7_pp_static_parameter) == 192);
3438 if (IS_GEN7(i965->intel.device_id))
3439 param_size = sizeof(struct gen7_pp_static_parameter);
3441 param_size = sizeof(struct pp_static_parameter);
3443 dri_bo_map(pp_context->curbe.bo, 1);
3444 assert(pp_context->curbe.bo->virtual);
3445 constant_buffer = pp_context->curbe.bo->virtual;
3446 memcpy(constant_buffer, pp_context->pp_static_parameter, param_size);
3447 dri_bo_unmap(pp_context->curbe.bo);
3451 gen6_pp_states_setup(VADriverContextP ctx,
3452 struct i965_post_processing_context *pp_context)
3454 gen6_pp_interface_descriptor_table(ctx, pp_context);
3455 gen6_pp_upload_constants(ctx, pp_context);
3459 gen6_pp_pipeline_select(VADriverContextP ctx,
3460 struct i965_post_processing_context *pp_context)
3462 struct intel_batchbuffer *batch = pp_context->batch;
3464 BEGIN_BATCH(batch, 1);
3465 OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA);
3466 ADVANCE_BATCH(batch);
3470 gen6_pp_state_base_address(VADriverContextP ctx,
3471 struct i965_post_processing_context *pp_context)
3473 struct intel_batchbuffer *batch = pp_context->batch;
3475 BEGIN_BATCH(batch, 10);
3476 OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | (10 - 2));
3477 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3478 OUT_RELOC(batch, pp_context->surface_state_binding_table.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY); /* Surface state base address */
3479 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3480 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3481 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3482 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3483 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3484 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3485 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3486 ADVANCE_BATCH(batch);
3490 gen6_pp_vfe_state(VADriverContextP ctx,
3491 struct i965_post_processing_context *pp_context)
3493 struct intel_batchbuffer *batch = pp_context->batch;
3495 BEGIN_BATCH(batch, 8);
3496 OUT_BATCH(batch, CMD_MEDIA_VFE_STATE | (8 - 2));
3497 OUT_BATCH(batch, 0);
3499 (pp_context->urb.num_vfe_entries - 1) << 16 |
3500 pp_context->urb.num_vfe_entries << 8);
3501 OUT_BATCH(batch, 0);
3503 (pp_context->urb.size_vfe_entry * 2) << 16 | /* URB Entry Allocation Size, in 256 bits unit */
3504 (pp_context->urb.size_cs_entry * pp_context->urb.num_cs_entries * 2)); /* CURBE Allocation Size, in 256 bits unit */
3505 OUT_BATCH(batch, 0);
3506 OUT_BATCH(batch, 0);
3507 OUT_BATCH(batch, 0);
3508 ADVANCE_BATCH(batch);
3512 gen6_pp_curbe_load(VADriverContextP ctx,
3513 struct i965_post_processing_context *pp_context)
3515 struct intel_batchbuffer *batch = pp_context->batch;
3517 assert(pp_context->urb.size_cs_entry * pp_context->urb.num_cs_entries * 2 * 32 <= pp_context->curbe.bo->size);
3519 BEGIN_BATCH(batch, 4);
3520 OUT_BATCH(batch, CMD_MEDIA_CURBE_LOAD | (4 - 2));
3521 OUT_BATCH(batch, 0);
3523 pp_context->urb.size_cs_entry * pp_context->urb.num_cs_entries * 2 * 32);
3525 pp_context->curbe.bo,
3526 I915_GEM_DOMAIN_INSTRUCTION, 0,
3528 ADVANCE_BATCH(batch);
3532 gen6_interface_descriptor_load(VADriverContextP ctx,
3533 struct i965_post_processing_context *pp_context)
3535 struct intel_batchbuffer *batch = pp_context->batch;
3537 BEGIN_BATCH(batch, 4);
3538 OUT_BATCH(batch, CMD_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2));
3539 OUT_BATCH(batch, 0);
3541 pp_context->idrt.num_interface_descriptors * sizeof(struct gen6_interface_descriptor_data));
3543 pp_context->idrt.bo,
3544 I915_GEM_DOMAIN_INSTRUCTION, 0,
3546 ADVANCE_BATCH(batch);
3550 gen6_pp_object_walker(VADriverContextP ctx,
3551 struct i965_post_processing_context *pp_context)
3553 struct i965_driver_data *i965 = i965_driver_data(ctx);
3554 struct intel_batchbuffer *batch = pp_context->batch;
3555 int x, x_steps, y, y_steps;
3556 int param_size, command_length_in_dws;
3557 dri_bo *command_buffer;
3558 unsigned int *command_ptr;
3560 if (IS_GEN7(i965->intel.device_id))
3561 param_size = sizeof(struct gen7_pp_inline_parameter);
3563 param_size = sizeof(struct pp_inline_parameter);
3565 x_steps = pp_context->pp_x_steps(&pp_context->private_context);
3566 y_steps = pp_context->pp_y_steps(&pp_context->private_context);
3567 command_length_in_dws = 6 + (param_size >> 2);
3568 command_buffer = dri_bo_alloc(i965->intel.bufmgr,
3569 "command objects buffer",
3570 command_length_in_dws * 4 * x_steps * y_steps + 8,
3573 dri_bo_map(command_buffer, 1);
3574 command_ptr = command_buffer->virtual;
3576 for (y = 0; y < y_steps; y++) {
3577 for (x = 0; x < x_steps; x++) {
3578 if (!pp_context->pp_set_block_parameter(pp_context, x, y)) {
3579 *command_ptr++ = (CMD_MEDIA_OBJECT | (command_length_in_dws - 2));
3585 memcpy(command_ptr, pp_context->pp_inline_parameter, param_size);
3586 command_ptr += (param_size >> 2);
3591 if (command_length_in_dws * x_steps * y_steps % 2 == 0)
3594 *command_ptr = MI_BATCH_BUFFER_END;
3596 dri_bo_unmap(command_buffer);
3598 BEGIN_BATCH(batch, 2);
3599 OUT_BATCH(batch, MI_BATCH_BUFFER_START | (2 << 6));
3600 OUT_RELOC(batch, command_buffer,
3601 I915_GEM_DOMAIN_COMMAND, 0,
3603 ADVANCE_BATCH(batch);
3605 dri_bo_unreference(command_buffer);
3607 /* Have to execute the batch buffer here becuase MI_BATCH_BUFFER_END
3608 * will cause control to pass back to ring buffer
3610 intel_batchbuffer_end_atomic(batch);
3611 intel_batchbuffer_flush(batch);
3612 intel_batchbuffer_start_atomic(batch, 0x1000);
3616 gen6_pp_pipeline_setup(VADriverContextP ctx,
3617 struct i965_post_processing_context *pp_context)
3619 struct intel_batchbuffer *batch = pp_context->batch;
3621 intel_batchbuffer_start_atomic(batch, 0x1000);
3622 intel_batchbuffer_emit_mi_flush(batch);
3623 gen6_pp_pipeline_select(ctx, pp_context);
3624 gen6_pp_state_base_address(ctx, pp_context);
3625 gen6_pp_vfe_state(ctx, pp_context);
3626 gen6_pp_curbe_load(ctx, pp_context);
3627 gen6_interface_descriptor_load(ctx, pp_context);
3628 gen6_pp_object_walker(ctx, pp_context);
3629 intel_batchbuffer_end_atomic(batch);
3633 gen6_post_processing(
3634 VADriverContextP ctx,
3635 struct i965_post_processing_context *pp_context,
3636 const struct i965_surface *src_surface,
3637 const VARectangle *src_rect,
3638 struct i965_surface *dst_surface,
3639 const VARectangle *dst_rect,
3646 va_status = gen6_pp_initialize(ctx, pp_context,
3654 if (va_status == VA_STATUS_SUCCESS) {
3655 gen6_pp_states_setup(ctx, pp_context);
3656 gen6_pp_pipeline_setup(ctx, pp_context);
3663 i965_post_processing_internal(
3664 VADriverContextP ctx,
3665 struct i965_post_processing_context *pp_context,
3666 const struct i965_surface *src_surface,
3667 const VARectangle *src_rect,
3668 struct i965_surface *dst_surface,
3669 const VARectangle *dst_rect,
3674 struct i965_driver_data *i965 = i965_driver_data(ctx);
3677 if (IS_GEN6(i965->intel.device_id) ||
3678 IS_GEN7(i965->intel.device_id))
3679 va_status = gen6_post_processing(ctx, pp_context, src_surface, src_rect, dst_surface, dst_rect, pp_index, filter_param);
3681 va_status = ironlake_post_processing(ctx, pp_context, src_surface, src_rect, dst_surface, dst_rect, pp_index, filter_param);
3687 i965_DestroySurfaces(VADriverContextP ctx,
3688 VASurfaceID *surface_list,
3691 i965_CreateSurfaces(VADriverContextP ctx,
3696 VASurfaceID *surfaces);
3699 rgb_to_yuv(unsigned int argb,
3705 int r = ((argb >> 16) & 0xff);
3706 int g = ((argb >> 8) & 0xff);
3707 int b = ((argb >> 0) & 0xff);
3709 *y = (257 * r + 504 * g + 98 * b) / 1000 + 16;
3710 *v = (439 * r - 368 * g - 71 * b) / 1000 + 128;
3711 *u = (-148 * r - 291 * g + 439 * b) / 1000 + 128;
3712 *a = ((argb >> 24) & 0xff);
3716 i965_vpp_clear_surface(VADriverContextP ctx,
3717 struct i965_post_processing_context *pp_context,
3718 VASurfaceID surface,
3721 struct i965_driver_data *i965 = i965_driver_data(ctx);
3722 struct intel_batchbuffer *batch = pp_context->batch;
3723 struct object_surface *obj_surface = SURFACE(surface);
3724 unsigned int blt_cmd, br13;
3725 unsigned int tiling = 0, swizzle = 0;
3727 unsigned char y, u, v, a;
3729 /* Currently only support NV12 surface */
3730 if (!obj_surface || obj_surface->fourcc != VA_FOURCC('N', 'V', '1', '2'))
3733 rgb_to_yuv(color, &y, &u, &v, &a);
3735 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
3736 blt_cmd = XY_COLOR_BLT_CMD;
3737 pitch = obj_surface->width;
3739 if (tiling != I915_TILING_NONE) {
3740 blt_cmd |= XY_COLOR_BLT_DST_TILED;
3748 if (IS_GEN6(i965->intel.device_id) ||
3749 IS_GEN7(i965->intel.device_id)) {
3750 intel_batchbuffer_start_atomic_blt(batch, 48);
3751 BEGIN_BLT_BATCH(batch, 12);
3753 intel_batchbuffer_start_atomic(batch, 48);
3754 BEGIN_BATCH(batch, 12);
3757 OUT_BATCH(batch, blt_cmd);
3758 OUT_BATCH(batch, br13);
3763 obj_surface->height << 16 |
3764 obj_surface->width);
3765 OUT_RELOC(batch, obj_surface->bo,
3766 I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
3768 OUT_BATCH(batch, y);
3774 OUT_BATCH(batch, blt_cmd);
3775 OUT_BATCH(batch, br13);
3780 obj_surface->height / 2 << 16 |
3781 obj_surface->width / 2);
3782 OUT_RELOC(batch, obj_surface->bo,
3783 I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
3784 obj_surface->width * obj_surface->y_cb_offset);
3785 OUT_BATCH(batch, v << 8 | u);
3787 ADVANCE_BATCH(batch);
3788 intel_batchbuffer_end_atomic(batch);
3792 i965_post_processing(
3793 VADriverContextP ctx,
3794 VASurfaceID surface,
3795 const VARectangle *src_rect,
3796 const VARectangle *dst_rect,
3798 int *has_done_scaling
3801 struct i965_driver_data *i965 = i965_driver_data(ctx);
3802 VASurfaceID in_surface_id = surface;
3803 VASurfaceID out_surface_id = VA_INVALID_ID;
3805 *has_done_scaling = 0;
3808 struct object_surface *obj_surface;
3810 struct i965_surface src_surface;
3811 struct i965_surface dst_surface;
3813 obj_surface = SURFACE(in_surface_id);
3815 /* Currently only support post processing for NV12 surface */
3816 if (obj_surface->fourcc != VA_FOURCC('N', 'V', '1', '2'))
3817 return out_surface_id;
3819 _i965LockMutex(&i965->pp_mutex);
3821 if (flags & I965_PP_FLAG_MCDI) {
3822 status = i965_CreateSurfaces(ctx,
3823 obj_surface->orig_width,
3824 obj_surface->orig_height,
3825 VA_RT_FORMAT_YUV420,
3828 assert(status == VA_STATUS_SUCCESS);
3829 obj_surface = SURFACE(out_surface_id);
3830 i965_check_alloc_surface_bo(ctx, obj_surface, 0, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
3831 i965_vpp_clear_surface(ctx, i965->pp_context, out_surface_id, 0);
3832 src_surface.id = in_surface_id;
3833 src_surface.type = I965_SURFACE_TYPE_SURFACE;
3834 src_surface.flags = (flags & I965_PP_FLAG_TOP_FIELD) ?
3835 I965_SURFACE_FLAG_TOP_FIELD_FIRST : I965_SURFACE_FLAG_BOTTOME_FIELD_FIRST;
3836 dst_surface.id = out_surface_id;
3837 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
3838 dst_surface.flags = I965_SURFACE_FLAG_FRAME;
3840 i965_post_processing_internal(ctx, i965->pp_context,
3849 if (flags & I965_PP_FLAG_AVS) {
3850 struct i965_render_state *render_state = &i965->render_state;
3851 struct intel_region *dest_region = render_state->draw_region;
3853 if (out_surface_id != VA_INVALID_ID)
3854 in_surface_id = out_surface_id;
3856 status = i965_CreateSurfaces(ctx,
3858 dest_region->height,
3859 VA_RT_FORMAT_YUV420,
3862 assert(status == VA_STATUS_SUCCESS);
3863 obj_surface = SURFACE(out_surface_id);
3864 i965_check_alloc_surface_bo(ctx, obj_surface, 0, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
3865 i965_vpp_clear_surface(ctx, i965->pp_context, out_surface_id, 0);
3866 src_surface.id = in_surface_id;
3867 src_surface.type = I965_SURFACE_TYPE_SURFACE;
3868 src_surface.flags = I965_SURFACE_FLAG_FRAME;
3869 dst_surface.id = out_surface_id;
3870 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
3871 dst_surface.flags = I965_SURFACE_FLAG_FRAME;
3873 i965_post_processing_internal(ctx, i965->pp_context,
3881 if (in_surface_id != surface)
3882 i965_DestroySurfaces(ctx, &in_surface_id, 1);
3884 *has_done_scaling = 1;
3887 _i965UnlockMutex(&i965->pp_mutex);
3890 return out_surface_id;
3894 i965_image_pl3_processing(VADriverContextP ctx,
3895 const struct i965_surface *src_surface,
3896 const VARectangle *src_rect,
3897 struct i965_surface *dst_surface,
3898 const VARectangle *dst_rect)
3900 struct i965_driver_data *i965 = i965_driver_data(ctx);
3901 struct i965_post_processing_context *pp_context = i965->pp_context;
3902 int fourcc = pp_get_surface_fourcc(ctx, dst_surface);
3904 if (fourcc == VA_FOURCC('N', 'V', '1', '2')) {
3905 i965_post_processing_internal(ctx, i965->pp_context,
3910 PP_PL3_LOAD_SAVE_N12,
3912 } else if (fourcc == VA_FOURCC('I', 'M', 'C', '1') ||
3913 fourcc == VA_FOURCC('I', 'M', 'C', '3')) {
3914 i965_post_processing_internal(ctx, i965->pp_context,
3919 PP_PL3_LOAD_SAVE_PL3,
3921 } else if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
3922 i965_post_processing_internal(ctx, i965->pp_context,
3927 PP_PL3_LOAD_SAVE_PA,
3935 intel_batchbuffer_flush(pp_context->batch);
3937 return VA_STATUS_SUCCESS;
3941 i965_image_pl2_processing(VADriverContextP ctx,
3942 const struct i965_surface *src_surface,
3943 const VARectangle *src_rect,
3944 struct i965_surface *dst_surface,
3945 const VARectangle *dst_rect)
3947 struct i965_driver_data *i965 = i965_driver_data(ctx);
3948 struct i965_post_processing_context *pp_context = i965->pp_context;
3949 int fourcc = pp_get_surface_fourcc(ctx, dst_surface);
3951 if (fourcc == VA_FOURCC('N', 'V', '1', '2')) {
3952 i965_post_processing_internal(ctx, i965->pp_context,
3957 PP_NV12_LOAD_SAVE_N12,
3959 } else if (fourcc == VA_FOURCC('I', 'M', 'C', '1') ||
3960 fourcc == VA_FOURCC('I', 'M', 'C', '3')) {
3961 i965_post_processing_internal(ctx, i965->pp_context,
3966 PP_NV12_LOAD_SAVE_PL3,
3968 } else if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
3969 i965_post_processing_internal(ctx, i965->pp_context,
3974 PP_NV12_LOAD_SAVE_PA,
3978 intel_batchbuffer_flush(pp_context->batch);
3980 return VA_STATUS_SUCCESS;
3984 i965_image_pl1_processing(VADriverContextP ctx,
3985 const struct i965_surface *src_surface,
3986 const VARectangle *src_rect,
3987 struct i965_surface *dst_surface,
3988 const VARectangle *dst_rect)
3990 struct i965_driver_data *i965 = i965_driver_data(ctx);
3991 struct i965_post_processing_context *pp_context = i965->pp_context;
3992 int fourcc = pp_get_surface_fourcc(ctx, dst_surface);
3994 if (fourcc == VA_FOURCC('N', 'V', '1', '2')) {
3995 i965_post_processing_internal(ctx, i965->pp_context,
4000 PP_PA_LOAD_SAVE_NV12,
4004 return VA_STATUS_ERROR_UNKNOWN;
4007 intel_batchbuffer_flush(pp_context->batch);
4009 return VA_STATUS_SUCCESS;
4013 i965_image_processing(VADriverContextP ctx,
4014 const struct i965_surface *src_surface,
4015 const VARectangle *src_rect,
4016 struct i965_surface *dst_surface,
4017 const VARectangle *dst_rect)
4019 struct i965_driver_data *i965 = i965_driver_data(ctx);
4020 VAStatus status = VA_STATUS_ERROR_UNIMPLEMENTED;
4023 int fourcc = pp_get_surface_fourcc(ctx, src_surface);
4025 _i965LockMutex(&i965->pp_mutex);
4028 case VA_FOURCC('Y', 'V', '1', '2'):
4029 case VA_FOURCC('I', '4', '2', '0'):
4030 case VA_FOURCC('I', 'M', 'C', '1'):
4031 case VA_FOURCC('I', 'M', 'C', '3'):
4032 status = i965_image_pl3_processing(ctx,
4039 case VA_FOURCC('N', 'V', '1', '2'):
4040 status = i965_image_pl2_processing(ctx,
4046 case VA_FOURCC('Y', 'U', 'Y', '2'):
4047 status = i965_image_pl1_processing(ctx,
4055 status = VA_STATUS_ERROR_UNIMPLEMENTED;
4059 _i965UnlockMutex(&i965->pp_mutex);
4066 i965_post_processing_context_finalize(struct i965_post_processing_context *pp_context)
4070 dri_bo_unreference(pp_context->surface_state_binding_table.bo);
4071 pp_context->surface_state_binding_table.bo = NULL;
4073 dri_bo_unreference(pp_context->curbe.bo);
4074 pp_context->curbe.bo = NULL;
4076 dri_bo_unreference(pp_context->sampler_state_table.bo);
4077 pp_context->sampler_state_table.bo = NULL;
4079 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8);
4080 pp_context->sampler_state_table.bo_8x8 = NULL;
4082 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8_uv);
4083 pp_context->sampler_state_table.bo_8x8_uv = NULL;
4085 dri_bo_unreference(pp_context->idrt.bo);
4086 pp_context->idrt.bo = NULL;
4087 pp_context->idrt.num_interface_descriptors = 0;
4089 dri_bo_unreference(pp_context->vfe_state.bo);
4090 pp_context->vfe_state.bo = NULL;
4092 dri_bo_unreference(pp_context->stmm.bo);
4093 pp_context->stmm.bo = NULL;
4095 for (i = 0; i < NUM_PP_MODULES; i++) {
4096 struct pp_module *pp_module = &pp_context->pp_modules[i];
4098 dri_bo_unreference(pp_module->kernel.bo);
4099 pp_module->kernel.bo = NULL;
4102 free(pp_context->pp_static_parameter);
4103 free(pp_context->pp_inline_parameter);
4104 pp_context->pp_static_parameter = NULL;
4105 pp_context->pp_inline_parameter = NULL;
4109 i965_post_processing_terminate(VADriverContextP ctx)
4111 struct i965_driver_data *i965 = i965_driver_data(ctx);
4112 struct i965_post_processing_context *pp_context = i965->pp_context;
4115 i965_post_processing_context_finalize(pp_context);
4119 i965->pp_context = NULL;
4125 i965_post_processing_context_init(VADriverContextP ctx,
4126 struct i965_post_processing_context *pp_context,
4127 struct intel_batchbuffer *batch)
4129 struct i965_driver_data *i965 = i965_driver_data(ctx);
4132 pp_context->urb.size = URB_SIZE((&i965->intel));
4133 pp_context->urb.num_vfe_entries = 32;
4134 pp_context->urb.size_vfe_entry = 1; /* in 512 bits unit */
4135 pp_context->urb.num_cs_entries = 1;
4137 if (IS_GEN7(i965->intel.device_id))
4138 pp_context->urb.size_cs_entry = 4; /* in 512 bits unit */
4140 pp_context->urb.size_cs_entry = 2;
4142 pp_context->urb.vfe_start = 0;
4143 pp_context->urb.cs_start = pp_context->urb.vfe_start +
4144 pp_context->urb.num_vfe_entries * pp_context->urb.size_vfe_entry;
4145 assert(pp_context->urb.cs_start +
4146 pp_context->urb.num_cs_entries * pp_context->urb.size_cs_entry <= URB_SIZE((&i965->intel)));
4148 assert(NUM_PP_MODULES == ARRAY_ELEMS(pp_modules_gen5));
4149 assert(NUM_PP_MODULES == ARRAY_ELEMS(pp_modules_gen6));
4150 assert(NUM_PP_MODULES == ARRAY_ELEMS(pp_modules_gen7));
4152 if (IS_GEN7(i965->intel.device_id))
4153 memcpy(pp_context->pp_modules, pp_modules_gen7, sizeof(pp_context->pp_modules));
4154 else if (IS_GEN6(i965->intel.device_id))
4155 memcpy(pp_context->pp_modules, pp_modules_gen6, sizeof(pp_context->pp_modules));
4156 else if (IS_IRONLAKE(i965->intel.device_id))
4157 memcpy(pp_context->pp_modules, pp_modules_gen5, sizeof(pp_context->pp_modules));
4159 for (i = 0; i < NUM_PP_MODULES; i++) {
4160 struct pp_module *pp_module = &pp_context->pp_modules[i];
4161 dri_bo_unreference(pp_module->kernel.bo);
4162 if (pp_module->kernel.bin && pp_module->kernel.size) {
4163 pp_module->kernel.bo = dri_bo_alloc(i965->intel.bufmgr,
4164 pp_module->kernel.name,
4165 pp_module->kernel.size,
4167 assert(pp_module->kernel.bo);
4168 dri_bo_subdata(pp_module->kernel.bo, 0, pp_module->kernel.size, pp_module->kernel.bin);
4170 pp_module->kernel.bo = NULL;
4174 /* static & inline parameters */
4175 if (IS_GEN7(i965->intel.device_id)) {
4176 pp_context->pp_static_parameter = calloc(sizeof(struct gen7_pp_static_parameter), 1);
4177 pp_context->pp_inline_parameter = calloc(sizeof(struct gen7_pp_inline_parameter), 1);
4179 pp_context->pp_static_parameter = calloc(sizeof(struct pp_static_parameter), 1);
4180 pp_context->pp_inline_parameter = calloc(sizeof(struct pp_inline_parameter), 1);
4183 pp_context->batch = batch;
4187 i965_post_processing_init(VADriverContextP ctx)
4189 struct i965_driver_data *i965 = i965_driver_data(ctx);
4190 struct i965_post_processing_context *pp_context = i965->pp_context;
4193 if (pp_context == NULL) {
4194 pp_context = calloc(1, sizeof(*pp_context));
4195 i965_post_processing_context_init(ctx, pp_context, i965->batch);
4196 i965->pp_context = pp_context;
4203 static const int procfilter_to_pp_flag[VAProcFilterCount] = {
4204 PP_NULL, /* VAProcFilterNone */
4205 PP_NV12_DN, /* VAProcFilterNoiseReduction */
4206 PP_NV12_DNDI, /* VAProcFilterDeinterlacing */
4207 PP_NULL, /* VAProcFilterSharpening */
4208 PP_NULL, /* VAProcFilterColorBalance */
4209 PP_NULL, /* VAProcFilterColorStandard */
4212 static const int proc_frame_to_pp_frame[3] = {
4213 I965_SURFACE_FLAG_FRAME,
4214 I965_SURFACE_FLAG_TOP_FIELD_FIRST,
4215 I965_SURFACE_FLAG_BOTTOME_FIELD_FIRST
4219 i965_proc_picture(VADriverContextP ctx,
4221 union codec_state *codec_state,
4222 struct hw_context *hw_context)
4224 struct i965_driver_data *i965 = i965_driver_data(ctx);
4225 struct i965_proc_context *proc_context = (struct i965_proc_context *)hw_context;
4226 struct proc_state *proc_state = &codec_state->proc;
4227 VAProcPipelineParameterBuffer *pipeline_param = (VAProcPipelineParameterBuffer *)proc_state->pipeline_param->buffer;
4228 struct object_surface *obj_surface;
4229 struct i965_surface src_surface, dst_surface;
4230 VARectangle src_rect, dst_rect;
4233 VASurfaceID tmp_surfaces[VAProcFilterCount + 4];
4234 int num_tmp_surfaces = 0;
4235 unsigned int tiling = 0, swizzle = 0;
4236 int in_width, in_height;
4238 assert(pipeline_param->surface != VA_INVALID_ID);
4239 assert(proc_state->current_render_target != VA_INVALID_ID);
4241 obj_surface = SURFACE(pipeline_param->surface);
4242 in_width = obj_surface->orig_width;
4243 in_height = obj_surface->orig_height;
4244 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
4246 src_surface.id = pipeline_param->surface;
4247 src_surface.type = I965_SURFACE_TYPE_SURFACE;
4248 src_surface.flags = proc_frame_to_pp_frame[pipeline_param->filter_flags & 0x3];
4250 if (obj_surface->fourcc != VA_FOURCC('N', 'V', '1', '2')) {
4251 VASurfaceID out_surface_id = VA_INVALID_ID;
4253 src_surface.id = pipeline_param->surface;
4254 src_surface.type = I965_SURFACE_TYPE_SURFACE;
4255 src_surface.flags = I965_SURFACE_FLAG_FRAME;
4258 src_rect.width = in_width;
4259 src_rect.height = in_height;
4261 status = i965_CreateSurfaces(ctx,
4264 VA_RT_FORMAT_YUV420,
4267 assert(status == VA_STATUS_SUCCESS);
4268 tmp_surfaces[num_tmp_surfaces++] = out_surface_id;
4269 obj_surface = SURFACE(out_surface_id);
4270 i965_check_alloc_surface_bo(ctx, obj_surface, !!tiling, VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
4272 dst_surface.id = out_surface_id;
4273 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
4274 dst_surface.flags = I965_SURFACE_FLAG_FRAME;
4277 dst_rect.width = in_width;
4278 dst_rect.height = in_height;
4280 status = i965_image_processing(ctx,
4285 assert(status == VA_STATUS_SUCCESS);
4287 src_surface.id = out_surface_id;
4288 src_surface.type = I965_SURFACE_TYPE_SURFACE;
4289 src_surface.flags = proc_frame_to_pp_frame[pipeline_param->filter_flags & 0x3];
4292 if (pipeline_param->surface_region) {
4293 src_rect.x = pipeline_param->surface_region->x;
4294 src_rect.y = pipeline_param->surface_region->y;
4295 src_rect.width = pipeline_param->surface_region->width;
4296 src_rect.height = pipeline_param->surface_region->height;
4300 src_rect.width = in_width;
4301 src_rect.height = in_height;
4304 if (pipeline_param->output_region) {
4305 dst_rect.x = pipeline_param->output_region->x;
4306 dst_rect.y = pipeline_param->output_region->y;
4307 dst_rect.width = pipeline_param->output_region->width;
4308 dst_rect.height = pipeline_param->output_region->height;
4312 dst_rect.width = in_width;
4313 dst_rect.height = in_height;
4316 obj_surface = SURFACE(proc_state->current_render_target);
4317 i965_check_alloc_surface_bo(ctx, obj_surface, !!tiling, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
4318 i965_vpp_clear_surface(ctx, &proc_context->pp_context, proc_state->current_render_target, pipeline_param->output_background_color);
4320 for (i = 0; i < pipeline_param->num_filters; i++) {
4321 struct object_buffer *obj_buffer = BUFFER(pipeline_param->filters[i]);
4322 VAProcFilterParameterBufferBase *filter_param = (VAProcFilterParameterBufferBase *)obj_buffer->buffer_store->buffer;
4323 VAProcFilterType filter_type = filter_param->type;
4324 VASurfaceID out_surface_id = VA_INVALID_ID;
4325 int kernel_index = procfilter_to_pp_flag[filter_type];
4327 if (kernel_index != PP_NULL &&
4328 proc_context->pp_context.pp_modules[kernel_index].kernel.bo != NULL) {
4329 status = i965_CreateSurfaces(ctx,
4332 VA_RT_FORMAT_YUV420,
4335 assert(status == VA_STATUS_SUCCESS);
4336 tmp_surfaces[num_tmp_surfaces++] = out_surface_id;
4337 obj_surface = SURFACE(out_surface_id);
4338 i965_check_alloc_surface_bo(ctx, obj_surface, !!tiling, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
4339 dst_surface.id = out_surface_id;
4340 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
4341 status = i965_post_processing_internal(ctx, &proc_context->pp_context,
4349 if (status == VA_STATUS_SUCCESS) {
4350 src_surface.id = dst_surface.id;
4351 src_surface.type = dst_surface.type;
4352 src_surface.flags = dst_surface.flags;
4357 dst_surface.id = proc_state->current_render_target;
4358 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
4360 if (src_rect.width == dst_rect.width &&
4361 src_rect.height == dst_rect.height) {
4362 i965_post_processing_internal(ctx, &proc_context->pp_context,
4367 PP_NV12_LOAD_SAVE_N12,
4371 i965_post_processing_internal(ctx, &proc_context->pp_context,
4376 (pipeline_param->filter_flags & VA_FILTER_SCALING_MASK) == VA_FILTER_SCALING_NL_ANAMORPHIC ?
4377 PP_NV12_AVS : PP_NV12_SCALING,
4381 if (num_tmp_surfaces)
4382 i965_DestroySurfaces(ctx,
4386 intel_batchbuffer_flush(hw_context->batch);
4390 i965_proc_context_destroy(void *hw_context)
4392 struct i965_proc_context *proc_context = (struct i965_proc_context *)hw_context;
4394 i965_post_processing_context_finalize(&proc_context->pp_context);
4395 intel_batchbuffer_free(proc_context->base.batch);
4400 i965_proc_context_init(VADriverContextP ctx, struct object_config *obj_config)
4402 struct intel_driver_data *intel = intel_driver_data(ctx);
4403 struct i965_proc_context *proc_context = calloc(1, sizeof(struct i965_proc_context));
4405 proc_context->base.destroy = i965_proc_context_destroy;
4406 proc_context->base.run = i965_proc_picture;
4407 proc_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
4408 i965_post_processing_context_init(ctx, &proc_context->pp_context, proc_context->base.batch);
4410 return (struct hw_context *)proc_context;