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 const uint32_t pp_pa_load_save_pl3_gen5[][4] = {
107 #include "shaders/post_processing/gen5_6/pa_load_save_pl3.g4b.gen5"
110 static VAStatus pp_null_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
111 const struct i965_surface *src_surface,
112 const VARectangle *src_rect,
113 struct i965_surface *dst_surface,
114 const VARectangle *dst_rect,
116 static VAStatus pp_nv12_avs_initialize_nlas(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
117 const struct i965_surface *src_surface,
118 const VARectangle *src_rect,
119 struct i965_surface *dst_surface,
120 const VARectangle *dst_rect,
122 static VAStatus pp_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
123 const struct i965_surface *src_surface,
124 const VARectangle *src_rect,
125 struct i965_surface *dst_surface,
126 const VARectangle *dst_rect,
128 static VAStatus gen6_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
129 const struct i965_surface *src_surface,
130 const VARectangle *src_rect,
131 struct i965_surface *dst_surface,
132 const VARectangle *dst_rect,
134 static VAStatus pp_plx_load_save_plx_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
135 const struct i965_surface *src_surface,
136 const VARectangle *src_rect,
137 struct i965_surface *dst_surface,
138 const VARectangle *dst_rect,
140 static VAStatus pp_nv12_dndi_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
141 const struct i965_surface *src_surface,
142 const VARectangle *src_rect,
143 struct i965_surface *dst_surface,
144 const VARectangle *dst_rect,
146 static VAStatus pp_nv12_dn_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
147 const struct i965_surface *src_surface,
148 const VARectangle *src_rect,
149 struct i965_surface *dst_surface,
150 const VARectangle *dst_rect,
153 static struct pp_module pp_modules_gen5[] = {
156 "NULL module (for testing)",
159 sizeof(pp_null_gen5),
169 PP_NV12_LOAD_SAVE_N12,
170 pp_nv12_load_save_nv12_gen5,
171 sizeof(pp_nv12_load_save_nv12_gen5),
175 pp_plx_load_save_plx_initialize,
181 PP_NV12_LOAD_SAVE_PL3,
182 pp_nv12_load_save_pl3_gen5,
183 sizeof(pp_nv12_load_save_pl3_gen5),
187 pp_plx_load_save_plx_initialize,
193 PP_PL3_LOAD_SAVE_N12,
194 pp_pl3_load_save_nv12_gen5,
195 sizeof(pp_pl3_load_save_nv12_gen5),
199 pp_plx_load_save_plx_initialize,
205 PP_PL3_LOAD_SAVE_N12,
206 pp_pl3_load_save_pl3_gen5,
207 sizeof(pp_pl3_load_save_pl3_gen5),
211 pp_plx_load_save_plx_initialize
216 "NV12 Scaling module",
218 pp_nv12_scaling_gen5,
219 sizeof(pp_nv12_scaling_gen5),
223 pp_nv12_scaling_initialize,
231 sizeof(pp_nv12_avs_gen5),
235 pp_nv12_avs_initialize_nlas,
243 sizeof(pp_nv12_dndi_gen5),
247 pp_nv12_dndi_initialize,
255 sizeof(pp_nv12_dn_gen5),
259 pp_nv12_dn_initialize,
265 PP_NV12_LOAD_SAVE_PA,
266 pp_nv12_load_save_pa_gen5,
267 sizeof(pp_nv12_load_save_pa_gen5),
271 pp_plx_load_save_plx_initialize,
278 pp_pl3_load_save_pa_gen5,
279 sizeof(pp_pl3_load_save_pa_gen5),
283 pp_plx_load_save_plx_initialize,
289 PP_PA_LOAD_SAVE_NV12,
290 pp_pa_load_save_nv12_gen5,
291 sizeof(pp_pa_load_save_nv12_gen5),
295 pp_plx_load_save_plx_initialize,
302 pp_pa_load_save_pl3_gen5,
303 sizeof(pp_pa_load_save_pl3_gen5),
307 pp_plx_load_save_plx_initialize,
312 static const uint32_t pp_null_gen6[][4] = {
313 #include "shaders/post_processing/gen5_6/null.g6b"
316 static const uint32_t pp_nv12_load_save_nv12_gen6[][4] = {
317 #include "shaders/post_processing/gen5_6/nv12_load_save_nv12.g6b"
320 static const uint32_t pp_nv12_load_save_pl3_gen6[][4] = {
321 #include "shaders/post_processing/gen5_6/nv12_load_save_pl3.g6b"
324 static const uint32_t pp_pl3_load_save_nv12_gen6[][4] = {
325 #include "shaders/post_processing/gen5_6/pl3_load_save_nv12.g6b"
328 static const uint32_t pp_pl3_load_save_pl3_gen6[][4] = {
329 #include "shaders/post_processing/gen5_6/pl3_load_save_pl3.g6b"
332 static const uint32_t pp_nv12_scaling_gen6[][4] = {
333 #include "shaders/post_processing/gen5_6/nv12_avs_nv12.g6b"
336 static const uint32_t pp_nv12_avs_gen6[][4] = {
337 #include "shaders/post_processing/gen5_6/nv12_avs_nv12.g6b"
340 static const uint32_t pp_nv12_dndi_gen6[][4] = {
341 #include "shaders/post_processing/gen5_6/nv12_dndi_nv12.g6b"
344 static const uint32_t pp_nv12_dn_gen6[][4] = {
345 #include "shaders/post_processing/gen5_6/nv12_dn_nv12.g6b"
348 static const uint32_t pp_nv12_load_save_pa_gen6[][4] = {
349 #include "shaders/post_processing/gen5_6/nv12_load_save_pa.g6b"
352 static const uint32_t pp_pl3_load_save_pa_gen6[][4] = {
353 #include "shaders/post_processing/gen5_6/pl3_load_save_pa.g6b"
356 static const uint32_t pp_pa_load_save_nv12_gen6[][4] = {
357 #include "shaders/post_processing/gen5_6/pa_load_save_nv12.g6b"
360 static const uint32_t pp_pa_load_save_pl3_gen6[][4] = {
361 #include "shaders/post_processing/gen5_6/pa_load_save_pl3.g6b"
364 static struct pp_module pp_modules_gen6[] = {
367 "NULL module (for testing)",
370 sizeof(pp_null_gen6),
380 PP_NV12_LOAD_SAVE_N12,
381 pp_nv12_load_save_nv12_gen6,
382 sizeof(pp_nv12_load_save_nv12_gen6),
386 pp_plx_load_save_plx_initialize,
392 PP_NV12_LOAD_SAVE_PL3,
393 pp_nv12_load_save_pl3_gen6,
394 sizeof(pp_nv12_load_save_pl3_gen6),
398 pp_plx_load_save_plx_initialize,
404 PP_PL3_LOAD_SAVE_N12,
405 pp_pl3_load_save_nv12_gen6,
406 sizeof(pp_pl3_load_save_nv12_gen6),
410 pp_plx_load_save_plx_initialize,
416 PP_PL3_LOAD_SAVE_N12,
417 pp_pl3_load_save_pl3_gen6,
418 sizeof(pp_pl3_load_save_pl3_gen6),
422 pp_plx_load_save_plx_initialize,
427 "NV12 Scaling module",
429 pp_nv12_scaling_gen6,
430 sizeof(pp_nv12_scaling_gen6),
434 gen6_nv12_scaling_initialize,
442 sizeof(pp_nv12_avs_gen6),
446 pp_nv12_avs_initialize_nlas,
454 sizeof(pp_nv12_dndi_gen6),
458 pp_nv12_dndi_initialize,
466 sizeof(pp_nv12_dn_gen6),
470 pp_nv12_dn_initialize,
475 PP_NV12_LOAD_SAVE_PA,
476 pp_nv12_load_save_pa_gen6,
477 sizeof(pp_nv12_load_save_pa_gen6),
481 pp_plx_load_save_plx_initialize,
488 pp_pl3_load_save_pa_gen6,
489 sizeof(pp_pl3_load_save_pa_gen6),
493 pp_plx_load_save_plx_initialize,
499 PP_PA_LOAD_SAVE_NV12,
500 pp_pa_load_save_nv12_gen6,
501 sizeof(pp_pa_load_save_nv12_gen6),
505 pp_plx_load_save_plx_initialize,
512 pp_pa_load_save_pl3_gen6,
513 sizeof(pp_pa_load_save_pl3_gen6),
517 pp_plx_load_save_plx_initialize,
522 static const uint32_t pp_null_gen7[][4] = {
525 static const uint32_t pp_nv12_load_save_nv12_gen7[][4] = {
526 #include "shaders/post_processing/gen7/pl2_to_pl2.g7b"
529 static const uint32_t pp_nv12_load_save_pl3_gen7[][4] = {
530 #include "shaders/post_processing/gen7/pl2_to_pl3.g7b"
533 static const uint32_t pp_pl3_load_save_nv12_gen7[][4] = {
534 #include "shaders/post_processing/gen7/pl3_to_pl2.g7b"
537 static const uint32_t pp_pl3_load_save_pl3_gen7[][4] = {
538 #include "shaders/post_processing/gen7/pl3_to_pl3.g7b"
541 static const uint32_t pp_nv12_scaling_gen7[][4] = {
542 #include "shaders/post_processing/gen7/avs.g7b"
545 static const uint32_t pp_nv12_avs_gen7[][4] = {
546 #include "shaders/post_processing/gen7/avs.g7b"
549 static const uint32_t pp_nv12_dndi_gen7[][4] = {
550 // #include "shaders/post_processing/gen7/dndi.g7b"
553 static const uint32_t pp_nv12_dn_gen7[][4] = {
555 static const uint32_t pp_nv12_load_save_pa_gen7[][4] = {
556 #include "shaders/post_processing/gen7/pl2_to_pa.g7b"
558 static const uint32_t pp_pl3_load_save_pa_gen7[][4] = {
559 #include "shaders/post_processing/gen7/pl3_to_pa.g7b"
561 static const uint32_t pp_pa_load_save_nv12_gen7[][4] = {
562 #include "shaders/post_processing/gen7/pa_to_pl2.g7b"
564 static const uint32_t pp_pa_load_save_pl3_gen7[][4] = {
565 #include "shaders/post_processing/gen7/pa_to_pl3.g7b"
568 static VAStatus gen7_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
569 const struct i965_surface *src_surface,
570 const VARectangle *src_rect,
571 struct i965_surface *dst_surface,
572 const VARectangle *dst_rect,
574 static VAStatus gen7_pp_nv12_dndi_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
575 const struct i965_surface *src_surface,
576 const VARectangle *src_rect,
577 struct i965_surface *dst_surface,
578 const VARectangle *dst_rect,
580 static VAStatus gen7_pp_nv12_dn_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
581 const struct i965_surface *src_surface,
582 const VARectangle *src_rect,
583 struct i965_surface *dst_surface,
584 const VARectangle *dst_rect,
587 static struct pp_module pp_modules_gen7[] = {
590 "NULL module (for testing)",
593 sizeof(pp_null_gen7),
603 PP_NV12_LOAD_SAVE_N12,
604 pp_nv12_load_save_nv12_gen7,
605 sizeof(pp_nv12_load_save_nv12_gen7),
609 gen7_pp_plx_avs_initialize,
615 PP_NV12_LOAD_SAVE_PL3,
616 pp_nv12_load_save_pl3_gen7,
617 sizeof(pp_nv12_load_save_pl3_gen7),
621 gen7_pp_plx_avs_initialize,
627 PP_PL3_LOAD_SAVE_N12,
628 pp_pl3_load_save_nv12_gen7,
629 sizeof(pp_pl3_load_save_nv12_gen7),
633 gen7_pp_plx_avs_initialize,
639 PP_PL3_LOAD_SAVE_N12,
640 pp_pl3_load_save_pl3_gen7,
641 sizeof(pp_pl3_load_save_pl3_gen7),
645 gen7_pp_plx_avs_initialize,
650 "NV12 Scaling module",
652 pp_nv12_scaling_gen7,
653 sizeof(pp_nv12_scaling_gen7),
657 gen7_pp_plx_avs_initialize,
665 sizeof(pp_nv12_avs_gen7),
669 gen7_pp_plx_avs_initialize,
677 sizeof(pp_nv12_dndi_gen7),
681 gen7_pp_nv12_dndi_initialize,
689 sizeof(pp_nv12_dn_gen7),
693 gen7_pp_nv12_dn_initialize,
698 PP_NV12_LOAD_SAVE_PA,
699 pp_nv12_load_save_pa_gen7,
700 sizeof(pp_nv12_load_save_pa_gen7),
704 gen7_pp_plx_avs_initialize,
711 pp_pl3_load_save_pa_gen7,
712 sizeof(pp_pl3_load_save_pa_gen7),
716 gen7_pp_plx_avs_initialize,
722 PP_PA_LOAD_SAVE_NV12,
723 pp_pa_load_save_nv12_gen7,
724 sizeof(pp_pa_load_save_nv12_gen7),
728 gen7_pp_plx_avs_initialize,
735 pp_pa_load_save_pl3_gen7,
736 sizeof(pp_pa_load_save_pl3_gen7),
740 gen7_pp_plx_avs_initialize,
746 pp_get_surface_fourcc(VADriverContextP ctx, const struct i965_surface *surface)
748 struct i965_driver_data *i965 = i965_driver_data(ctx);
751 if (surface->type == I965_SURFACE_TYPE_IMAGE) {
752 struct object_image *obj_image = IMAGE(surface->id);
753 fourcc = obj_image->image.format.fourcc;
755 struct object_surface *obj_surface = SURFACE(surface->id);
756 fourcc = obj_surface->fourcc;
763 pp_set_surface_tiling(struct i965_surface_state *ss, unsigned int tiling)
766 case I915_TILING_NONE:
767 ss->ss3.tiled_surface = 0;
768 ss->ss3.tile_walk = 0;
771 ss->ss3.tiled_surface = 1;
772 ss->ss3.tile_walk = I965_TILEWALK_XMAJOR;
775 ss->ss3.tiled_surface = 1;
776 ss->ss3.tile_walk = I965_TILEWALK_YMAJOR;
782 pp_set_surface2_tiling(struct i965_surface_state2 *ss, unsigned int tiling)
785 case I915_TILING_NONE:
786 ss->ss2.tiled_surface = 0;
787 ss->ss2.tile_walk = 0;
790 ss->ss2.tiled_surface = 1;
791 ss->ss2.tile_walk = I965_TILEWALK_XMAJOR;
794 ss->ss2.tiled_surface = 1;
795 ss->ss2.tile_walk = I965_TILEWALK_YMAJOR;
801 gen7_pp_set_surface_tiling(struct gen7_surface_state *ss, unsigned int tiling)
804 case I915_TILING_NONE:
805 ss->ss0.tiled_surface = 0;
806 ss->ss0.tile_walk = 0;
809 ss->ss0.tiled_surface = 1;
810 ss->ss0.tile_walk = I965_TILEWALK_XMAJOR;
813 ss->ss0.tiled_surface = 1;
814 ss->ss0.tile_walk = I965_TILEWALK_YMAJOR;
820 gen7_pp_set_surface2_tiling(struct gen7_surface_state2 *ss, unsigned int tiling)
823 case I915_TILING_NONE:
824 ss->ss2.tiled_surface = 0;
825 ss->ss2.tile_walk = 0;
828 ss->ss2.tiled_surface = 1;
829 ss->ss2.tile_walk = I965_TILEWALK_XMAJOR;
832 ss->ss2.tiled_surface = 1;
833 ss->ss2.tile_walk = I965_TILEWALK_YMAJOR;
839 ironlake_pp_interface_descriptor_table(struct i965_post_processing_context *pp_context)
841 struct i965_interface_descriptor *desc;
843 int pp_index = pp_context->current_pp;
845 bo = pp_context->idrt.bo;
849 memset(desc, 0, sizeof(*desc));
850 desc->desc0.grf_reg_blocks = 10;
851 desc->desc0.kernel_start_pointer = pp_context->pp_modules[pp_index].kernel.bo->offset >> 6; /* reloc */
852 desc->desc1.const_urb_entry_read_offset = 0;
853 desc->desc1.const_urb_entry_read_len = 4; /* grf 1-4 */
854 desc->desc2.sampler_state_pointer = pp_context->sampler_state_table.bo->offset >> 5;
855 desc->desc2.sampler_count = 0;
856 desc->desc3.binding_table_entry_count = 0;
857 desc->desc3.binding_table_pointer = (BINDING_TABLE_OFFSET >> 5);
859 dri_bo_emit_reloc(bo,
860 I915_GEM_DOMAIN_INSTRUCTION, 0,
861 desc->desc0.grf_reg_blocks,
862 offsetof(struct i965_interface_descriptor, desc0),
863 pp_context->pp_modules[pp_index].kernel.bo);
865 dri_bo_emit_reloc(bo,
866 I915_GEM_DOMAIN_INSTRUCTION, 0,
867 desc->desc2.sampler_count << 2,
868 offsetof(struct i965_interface_descriptor, desc2),
869 pp_context->sampler_state_table.bo);
872 pp_context->idrt.num_interface_descriptors++;
876 ironlake_pp_vfe_state(struct i965_post_processing_context *pp_context)
878 struct i965_vfe_state *vfe_state;
881 bo = pp_context->vfe_state.bo;
884 vfe_state = bo->virtual;
885 memset(vfe_state, 0, sizeof(*vfe_state));
886 vfe_state->vfe1.max_threads = pp_context->urb.num_vfe_entries - 1;
887 vfe_state->vfe1.urb_entry_alloc_size = pp_context->urb.size_vfe_entry - 1;
888 vfe_state->vfe1.num_urb_entries = pp_context->urb.num_vfe_entries;
889 vfe_state->vfe1.vfe_mode = VFE_GENERIC_MODE;
890 vfe_state->vfe1.children_present = 0;
891 vfe_state->vfe2.interface_descriptor_base =
892 pp_context->idrt.bo->offset >> 4; /* reloc */
893 dri_bo_emit_reloc(bo,
894 I915_GEM_DOMAIN_INSTRUCTION, 0,
896 offsetof(struct i965_vfe_state, vfe2),
897 pp_context->idrt.bo);
902 ironlake_pp_upload_constants(struct i965_post_processing_context *pp_context)
904 unsigned char *constant_buffer;
905 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
907 assert(sizeof(*pp_static_parameter) == 128);
908 dri_bo_map(pp_context->curbe.bo, 1);
909 assert(pp_context->curbe.bo->virtual);
910 constant_buffer = pp_context->curbe.bo->virtual;
911 memcpy(constant_buffer, pp_static_parameter, sizeof(*pp_static_parameter));
912 dri_bo_unmap(pp_context->curbe.bo);
916 ironlake_pp_states_setup(VADriverContextP ctx,
917 struct i965_post_processing_context *pp_context)
919 ironlake_pp_interface_descriptor_table(pp_context);
920 ironlake_pp_vfe_state(pp_context);
921 ironlake_pp_upload_constants(pp_context);
925 ironlake_pp_pipeline_select(VADriverContextP ctx,
926 struct i965_post_processing_context *pp_context)
928 struct intel_batchbuffer *batch = pp_context->batch;
930 BEGIN_BATCH(batch, 1);
931 OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA);
932 ADVANCE_BATCH(batch);
936 ironlake_pp_urb_layout(VADriverContextP ctx,
937 struct i965_post_processing_context *pp_context)
939 struct intel_batchbuffer *batch = pp_context->batch;
940 unsigned int vfe_fence, cs_fence;
942 vfe_fence = pp_context->urb.cs_start;
943 cs_fence = pp_context->urb.size;
945 BEGIN_BATCH(batch, 3);
946 OUT_BATCH(batch, CMD_URB_FENCE | UF0_VFE_REALLOC | UF0_CS_REALLOC | 1);
949 (vfe_fence << UF2_VFE_FENCE_SHIFT) | /* VFE_SIZE */
950 (cs_fence << UF2_CS_FENCE_SHIFT)); /* CS_SIZE */
951 ADVANCE_BATCH(batch);
955 ironlake_pp_state_base_address(VADriverContextP ctx,
956 struct i965_post_processing_context *pp_context)
958 struct intel_batchbuffer *batch = pp_context->batch;
960 BEGIN_BATCH(batch, 8);
961 OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | 6);
962 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
963 OUT_RELOC(batch, pp_context->surface_state_binding_table.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);
964 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
965 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
966 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
967 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
968 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
969 ADVANCE_BATCH(batch);
973 ironlake_pp_state_pointers(VADriverContextP ctx,
974 struct i965_post_processing_context *pp_context)
976 struct intel_batchbuffer *batch = pp_context->batch;
978 BEGIN_BATCH(batch, 3);
979 OUT_BATCH(batch, CMD_MEDIA_STATE_POINTERS | 1);
981 OUT_RELOC(batch, pp_context->vfe_state.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
982 ADVANCE_BATCH(batch);
986 ironlake_pp_cs_urb_layout(VADriverContextP ctx,
987 struct i965_post_processing_context *pp_context)
989 struct intel_batchbuffer *batch = pp_context->batch;
991 BEGIN_BATCH(batch, 2);
992 OUT_BATCH(batch, CMD_CS_URB_STATE | 0);
994 ((pp_context->urb.size_cs_entry - 1) << 4) | /* URB Entry Allocation Size */
995 (pp_context->urb.num_cs_entries << 0)); /* Number of URB Entries */
996 ADVANCE_BATCH(batch);
1000 ironlake_pp_constant_buffer(VADriverContextP ctx,
1001 struct i965_post_processing_context *pp_context)
1003 struct intel_batchbuffer *batch = pp_context->batch;
1005 BEGIN_BATCH(batch, 2);
1006 OUT_BATCH(batch, CMD_CONSTANT_BUFFER | (1 << 8) | (2 - 2));
1007 OUT_RELOC(batch, pp_context->curbe.bo,
1008 I915_GEM_DOMAIN_INSTRUCTION, 0,
1009 pp_context->urb.size_cs_entry - 1);
1010 ADVANCE_BATCH(batch);
1014 ironlake_pp_object_walker(VADriverContextP ctx,
1015 struct i965_post_processing_context *pp_context)
1017 struct intel_batchbuffer *batch = pp_context->batch;
1018 int x, x_steps, y, y_steps;
1019 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1021 x_steps = pp_context->pp_x_steps(&pp_context->private_context);
1022 y_steps = pp_context->pp_y_steps(&pp_context->private_context);
1024 for (y = 0; y < y_steps; y++) {
1025 for (x = 0; x < x_steps; x++) {
1026 if (!pp_context->pp_set_block_parameter(pp_context, x, y)) {
1027 BEGIN_BATCH(batch, 20);
1028 OUT_BATCH(batch, CMD_MEDIA_OBJECT | 18);
1029 OUT_BATCH(batch, 0);
1030 OUT_BATCH(batch, 0); /* no indirect data */
1031 OUT_BATCH(batch, 0);
1033 /* inline data grf 5-6 */
1034 assert(sizeof(*pp_inline_parameter) == 64);
1035 intel_batchbuffer_data(batch, pp_inline_parameter, sizeof(*pp_inline_parameter));
1037 ADVANCE_BATCH(batch);
1044 ironlake_pp_pipeline_setup(VADriverContextP ctx,
1045 struct i965_post_processing_context *pp_context)
1047 struct intel_batchbuffer *batch = pp_context->batch;
1049 intel_batchbuffer_start_atomic(batch, 0x1000);
1050 intel_batchbuffer_emit_mi_flush(batch);
1051 ironlake_pp_pipeline_select(ctx, pp_context);
1052 ironlake_pp_state_base_address(ctx, pp_context);
1053 ironlake_pp_state_pointers(ctx, pp_context);
1054 ironlake_pp_urb_layout(ctx, pp_context);
1055 ironlake_pp_cs_urb_layout(ctx, pp_context);
1056 ironlake_pp_constant_buffer(ctx, pp_context);
1057 ironlake_pp_object_walker(ctx, pp_context);
1058 intel_batchbuffer_end_atomic(batch);
1061 // update u/v offset when the surface format are packed yuv
1062 static void i965_update_src_surface_uv_offset(
1063 VADriverContextP ctx,
1064 struct i965_post_processing_context *pp_context,
1065 const struct i965_surface *surface)
1067 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1068 int fourcc = pp_get_surface_fourcc(ctx, surface);
1070 if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
1071 pp_static_parameter->grf1.source_packed_u_offset = 1;
1072 pp_static_parameter->grf1.source_packed_v_offset = 3;
1074 else if (fourcc == VA_FOURCC('U', 'Y', 'V', 'Y')) {
1075 pp_static_parameter->grf1.source_packed_y_offset = 1;
1076 pp_static_parameter->grf1.source_packed_v_offset = 2;
1081 static void i965_update_dst_surface_uv_offset(
1082 VADriverContextP ctx,
1083 struct i965_post_processing_context *pp_context,
1084 const struct i965_surface *surface)
1086 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1087 int fourcc = pp_get_surface_fourcc(ctx, surface);
1089 if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
1090 pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_u_offset = 1;
1091 pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_v_offset = 3;
1093 else if (fourcc == VA_FOURCC('U', 'Y', 'V', 'Y')) {
1094 pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_y_offset = 1;
1095 pp_static_parameter->grf1.r1_2.load_and_save.destination_packed_v_offset = 2;
1101 i965_pp_set_surface_state(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1102 dri_bo *surf_bo, unsigned long surf_bo_offset,
1103 int width, int height, int pitch, int format,
1104 int index, int is_target)
1106 struct i965_surface_state *ss;
1108 unsigned int tiling;
1109 unsigned int swizzle;
1111 dri_bo_get_tiling(surf_bo, &tiling, &swizzle);
1112 ss_bo = pp_context->surface_state_binding_table.bo;
1115 dri_bo_map(ss_bo, True);
1116 assert(ss_bo->virtual);
1117 ss = (struct i965_surface_state *)((char *)ss_bo->virtual + SURFACE_STATE_OFFSET(index));
1118 memset(ss, 0, sizeof(*ss));
1119 ss->ss0.surface_type = I965_SURFACE_2D;
1120 ss->ss0.surface_format = format;
1121 ss->ss1.base_addr = surf_bo->offset + surf_bo_offset;
1122 ss->ss2.width = width - 1;
1123 ss->ss2.height = height - 1;
1124 ss->ss3.pitch = pitch - 1;
1125 pp_set_surface_tiling(ss, tiling);
1126 dri_bo_emit_reloc(ss_bo,
1127 I915_GEM_DOMAIN_RENDER, is_target ? I915_GEM_DOMAIN_RENDER : 0,
1129 SURFACE_STATE_OFFSET(index) + offsetof(struct i965_surface_state, ss1),
1131 ((unsigned int *)((char *)ss_bo->virtual + BINDING_TABLE_OFFSET))[index] = SURFACE_STATE_OFFSET(index);
1132 dri_bo_unmap(ss_bo);
1136 i965_pp_set_surface2_state(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1137 dri_bo *surf_bo, unsigned long surf_bo_offset,
1138 int width, int height, int wpitch,
1139 int xoffset, int yoffset,
1140 int format, int interleave_chroma,
1143 struct i965_surface_state2 *ss2;
1145 unsigned int tiling;
1146 unsigned int swizzle;
1148 dri_bo_get_tiling(surf_bo, &tiling, &swizzle);
1149 ss2_bo = pp_context->surface_state_binding_table.bo;
1152 dri_bo_map(ss2_bo, True);
1153 assert(ss2_bo->virtual);
1154 ss2 = (struct i965_surface_state2 *)((char *)ss2_bo->virtual + SURFACE_STATE_OFFSET(index));
1155 memset(ss2, 0, sizeof(*ss2));
1156 ss2->ss0.surface_base_address = surf_bo->offset + surf_bo_offset;
1157 ss2->ss1.cbcr_pixel_offset_v_direction = 0;
1158 ss2->ss1.width = width - 1;
1159 ss2->ss1.height = height - 1;
1160 ss2->ss2.pitch = wpitch - 1;
1161 ss2->ss2.interleave_chroma = interleave_chroma;
1162 ss2->ss2.surface_format = format;
1163 ss2->ss3.x_offset_for_cb = xoffset;
1164 ss2->ss3.y_offset_for_cb = yoffset;
1165 pp_set_surface2_tiling(ss2, tiling);
1166 dri_bo_emit_reloc(ss2_bo,
1167 I915_GEM_DOMAIN_RENDER, 0,
1169 SURFACE_STATE_OFFSET(index) + offsetof(struct i965_surface_state2, ss0),
1171 ((unsigned int *)((char *)ss2_bo->virtual + BINDING_TABLE_OFFSET))[index] = SURFACE_STATE_OFFSET(index);
1172 dri_bo_unmap(ss2_bo);
1176 gen7_pp_set_surface_state(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1177 dri_bo *surf_bo, unsigned long surf_bo_offset,
1178 int width, int height, int pitch, int format,
1179 int index, int is_target)
1181 struct gen7_surface_state *ss;
1183 unsigned int tiling;
1184 unsigned int swizzle;
1186 dri_bo_get_tiling(surf_bo, &tiling, &swizzle);
1187 ss_bo = pp_context->surface_state_binding_table.bo;
1190 dri_bo_map(ss_bo, True);
1191 assert(ss_bo->virtual);
1192 ss = (struct gen7_surface_state *)((char *)ss_bo->virtual + SURFACE_STATE_OFFSET(index));
1193 memset(ss, 0, sizeof(*ss));
1194 ss->ss0.surface_type = I965_SURFACE_2D;
1195 ss->ss0.surface_format = format;
1196 ss->ss1.base_addr = surf_bo->offset + surf_bo_offset;
1197 ss->ss2.width = width - 1;
1198 ss->ss2.height = height - 1;
1199 ss->ss3.pitch = pitch - 1;
1200 gen7_pp_set_surface_tiling(ss, tiling);
1201 dri_bo_emit_reloc(ss_bo,
1202 I915_GEM_DOMAIN_RENDER, is_target ? I915_GEM_DOMAIN_RENDER : 0,
1204 SURFACE_STATE_OFFSET(index) + offsetof(struct gen7_surface_state, ss1),
1206 ((unsigned int *)((char *)ss_bo->virtual + BINDING_TABLE_OFFSET))[index] = SURFACE_STATE_OFFSET(index);
1207 dri_bo_unmap(ss_bo);
1211 gen7_pp_set_surface2_state(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1212 dri_bo *surf_bo, unsigned long surf_bo_offset,
1213 int width, int height, int wpitch,
1214 int xoffset, int yoffset,
1215 int format, int interleave_chroma,
1218 struct gen7_surface_state2 *ss2;
1220 unsigned int tiling;
1221 unsigned int swizzle;
1223 dri_bo_get_tiling(surf_bo, &tiling, &swizzle);
1224 ss2_bo = pp_context->surface_state_binding_table.bo;
1227 dri_bo_map(ss2_bo, True);
1228 assert(ss2_bo->virtual);
1229 ss2 = (struct gen7_surface_state2 *)((char *)ss2_bo->virtual + SURFACE_STATE_OFFSET(index));
1230 memset(ss2, 0, sizeof(*ss2));
1231 ss2->ss0.surface_base_address = surf_bo->offset + surf_bo_offset;
1232 ss2->ss1.cbcr_pixel_offset_v_direction = 0;
1233 ss2->ss1.width = width - 1;
1234 ss2->ss1.height = height - 1;
1235 ss2->ss2.pitch = wpitch - 1;
1236 ss2->ss2.interleave_chroma = interleave_chroma;
1237 ss2->ss2.surface_format = format;
1238 ss2->ss3.x_offset_for_cb = xoffset;
1239 ss2->ss3.y_offset_for_cb = yoffset;
1240 gen7_pp_set_surface2_tiling(ss2, tiling);
1241 dri_bo_emit_reloc(ss2_bo,
1242 I915_GEM_DOMAIN_RENDER, 0,
1244 SURFACE_STATE_OFFSET(index) + offsetof(struct gen7_surface_state2, ss0),
1246 ((unsigned int *)((char *)ss2_bo->virtual + BINDING_TABLE_OFFSET))[index] = SURFACE_STATE_OFFSET(index);
1247 dri_bo_unmap(ss2_bo);
1251 pp_set_media_rw_message_surface(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1252 const struct i965_surface *surface,
1253 int base_index, int is_target,
1254 int *width, int *height, int *pitch, int *offset)
1256 struct i965_driver_data *i965 = i965_driver_data(ctx);
1257 struct object_surface *obj_surface;
1258 struct object_image *obj_image;
1260 int fourcc = pp_get_surface_fourcc(ctx, surface);
1262 const int U = fourcc == VA_FOURCC('Y', 'V', '1', '2') ? 2 : 1;
1263 const int V = fourcc == VA_FOURCC('Y', 'V', '1', '2') ? 1 : 2;
1265 int interleaved_uv = fourcc == VA_FOURCC('N', 'V', '1', '2');
1266 int packed_yuv = (fourcc == VA_FOURCC('Y', 'U', 'Y', '2') || fourcc == VA_FOURCC('U', 'Y', 'V', 'Y'));
1268 if (surface->type == I965_SURFACE_TYPE_SURFACE) {
1269 obj_surface = SURFACE(surface->id);
1270 bo = obj_surface->bo;
1271 width[0] = obj_surface->orig_width;
1272 height[0] = obj_surface->orig_height;
1273 pitch[0] = obj_surface->width;
1277 width[0] = obj_surface->orig_width * 2;
1278 pitch[0] = obj_surface->width * 2;
1280 else if (interleaved_uv) {
1281 width[1] = obj_surface->orig_width;
1282 height[1] = obj_surface->orig_height / 2;
1283 pitch[1] = obj_surface->width;
1284 offset[1] = offset[0] + obj_surface->width * obj_surface->height;
1286 width[1] = obj_surface->orig_width / 2;
1287 height[1] = obj_surface->orig_height / 2;
1288 pitch[1] = obj_surface->width / 2;
1289 offset[1] = offset[0] + obj_surface->width * obj_surface->height;
1290 width[2] = obj_surface->orig_width / 2;
1291 height[2] = obj_surface->orig_height / 2;
1292 pitch[2] = obj_surface->width / 2;
1293 offset[2] = offset[1] + (obj_surface->width / 2) * (obj_surface->height / 2);
1296 obj_image = IMAGE(surface->id);
1298 width[0] = obj_image->image.width;
1299 height[0] = obj_image->image.height;
1300 pitch[0] = obj_image->image.pitches[0];
1301 offset[0] = obj_image->image.offsets[0];
1304 width[0] = obj_image->image.width * 2;
1306 else if (interleaved_uv) {
1307 width[1] = obj_image->image.width;
1308 height[1] = obj_image->image.height / 2;
1309 pitch[1] = obj_image->image.pitches[1];
1310 offset[1] = obj_image->image.offsets[1];
1312 width[1] = obj_image->image.width / 2;
1313 height[1] = obj_image->image.height / 2;
1314 pitch[1] = obj_image->image.pitches[1];
1315 offset[1] = obj_image->image.offsets[1];
1316 width[2] = obj_image->image.width / 2;
1317 height[2] = obj_image->image.height / 2;
1318 pitch[2] = obj_image->image.pitches[2];
1319 offset[2] = obj_image->image.offsets[2];
1324 i965_pp_set_surface_state(ctx, pp_context,
1326 width[Y] / 4, height[Y], pitch[Y], I965_SURFACEFORMAT_R8_UNORM,
1327 base_index, is_target);
1330 if (interleaved_uv) {
1331 i965_pp_set_surface_state(ctx, pp_context,
1333 width[UV] / 4, height[UV], pitch[UV], I965_SURFACEFORMAT_R8_UNORM,
1334 base_index + 1, is_target);
1337 i965_pp_set_surface_state(ctx, pp_context,
1339 width[U] / 4, height[U], pitch[U], I965_SURFACEFORMAT_R8_UNORM,
1340 base_index + 1, is_target);
1343 i965_pp_set_surface_state(ctx, pp_context,
1345 width[V] / 4, height[V], pitch[V], I965_SURFACEFORMAT_R8_UNORM,
1346 base_index + 2, is_target);
1353 gen7_pp_set_media_rw_message_surface(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1354 const struct i965_surface *surface,
1355 int base_index, int is_target,
1356 int *width, int *height, int *pitch, int *offset)
1358 struct i965_driver_data *i965 = i965_driver_data(ctx);
1359 struct object_surface *obj_surface;
1360 struct object_image *obj_image;
1362 int fourcc = pp_get_surface_fourcc(ctx, surface);
1363 const int U = (fourcc == VA_FOURCC('Y', 'V', '1', '2') ||
1364 fourcc == VA_FOURCC('I', 'M', 'C', '1')) ? 2 : 1;
1365 const int V = (fourcc == VA_FOURCC('Y', 'V', '1', '2') ||
1366 fourcc == VA_FOURCC('I', 'M', 'C', '1')) ? 1 : 2;
1367 int interleaved_uv = fourcc == VA_FOURCC('N', 'V', '1', '2');
1368 int packed_yuv = (fourcc == VA_FOURCC('Y', 'U', 'Y', '2'));
1370 if (surface->type == I965_SURFACE_TYPE_SURFACE) {
1371 obj_surface = SURFACE(surface->id);
1372 bo = obj_surface->bo;
1373 width[0] = obj_surface->orig_width;
1374 height[0] = obj_surface->orig_height;
1375 pitch[0] = obj_surface->width;
1380 width[0] = obj_surface->orig_width * 2; /* surface format is R8, so double the width */
1382 width[0] = obj_surface->orig_width; /* surface foramt is YCBCR, width is specified in units of pixels */
1384 pitch[0] = obj_surface->width * 2;
1387 width[1] = obj_surface->cb_cr_width;
1388 height[1] = obj_surface->cb_cr_height;
1389 pitch[1] = obj_surface->cb_cr_pitch;
1390 offset[1] = obj_surface->y_cb_offset * obj_surface->width;
1392 width[2] = obj_surface->cb_cr_width;
1393 height[2] = obj_surface->cb_cr_height;
1394 pitch[2] = obj_surface->cb_cr_pitch;
1395 offset[2] = obj_surface->y_cr_offset * obj_surface->width;
1397 obj_image = IMAGE(surface->id);
1399 width[0] = obj_image->image.width;
1400 height[0] = obj_image->image.height;
1401 pitch[0] = obj_image->image.pitches[0];
1402 offset[0] = obj_image->image.offsets[0];
1406 width[0] = obj_image->image.width * 2; /* surface format is R8, so double the width */
1408 width[0] = obj_image->image.width; /* surface foramt is YCBCR, width is specified in units of pixels */
1409 } else if (interleaved_uv) {
1410 width[1] = obj_image->image.width / 2;
1411 height[1] = obj_image->image.height / 2;
1412 pitch[1] = obj_image->image.pitches[1];
1413 offset[1] = obj_image->image.offsets[1];
1415 width[1] = obj_image->image.width / 2;
1416 height[1] = obj_image->image.height / 2;
1417 pitch[1] = obj_image->image.pitches[U];
1418 offset[1] = obj_image->image.offsets[U];
1419 width[2] = obj_image->image.width / 2;
1420 height[2] = obj_image->image.height / 2;
1421 pitch[2] = obj_image->image.pitches[V];
1422 offset[2] = obj_image->image.offsets[V];
1427 gen7_pp_set_surface_state(ctx, pp_context,
1429 width[0] / 4, height[0], pitch[0],
1430 I965_SURFACEFORMAT_R8_SINT,
1434 if (interleaved_uv) {
1435 gen7_pp_set_surface_state(ctx, pp_context,
1437 width[1] / 2, height[1], pitch[1],
1438 I965_SURFACEFORMAT_R8G8_SINT,
1441 gen7_pp_set_surface_state(ctx, pp_context,
1443 width[1] / 4, height[1], pitch[1],
1444 I965_SURFACEFORMAT_R8_SINT,
1446 gen7_pp_set_surface_state(ctx, pp_context,
1448 width[2] / 4, height[2], pitch[2],
1449 I965_SURFACEFORMAT_R8_SINT,
1454 int format0 = SURFACE_FORMAT_Y8_UNORM;
1457 case VA_FOURCC('Y', 'U', 'Y', '2'):
1458 format0 = SURFACE_FORMAT_YCRCB_NORMAL;
1465 gen7_pp_set_surface2_state(ctx, pp_context,
1467 width[0], height[0], pitch[0],
1473 if (interleaved_uv) {
1474 gen7_pp_set_surface2_state(ctx, pp_context,
1476 width[1], height[1], pitch[1],
1478 SURFACE_FORMAT_R8B8_UNORM, 0,
1481 gen7_pp_set_surface2_state(ctx, pp_context,
1483 width[1], height[1], pitch[1],
1485 SURFACE_FORMAT_R8_UNORM, 0,
1487 gen7_pp_set_surface2_state(ctx, pp_context,
1489 width[2], height[2], pitch[2],
1491 SURFACE_FORMAT_R8_UNORM, 0,
1499 pp_null_x_steps(void *private_context)
1505 pp_null_y_steps(void *private_context)
1511 pp_null_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
1517 pp_null_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1518 const struct i965_surface *src_surface,
1519 const VARectangle *src_rect,
1520 struct i965_surface *dst_surface,
1521 const VARectangle *dst_rect,
1524 /* private function & data */
1525 pp_context->pp_x_steps = pp_null_x_steps;
1526 pp_context->pp_y_steps = pp_null_y_steps;
1527 pp_context->pp_set_block_parameter = pp_null_set_block_parameter;
1529 dst_surface->flags = src_surface->flags;
1531 return VA_STATUS_SUCCESS;
1535 pp_load_save_x_steps(void *private_context)
1541 pp_load_save_y_steps(void *private_context)
1543 struct pp_load_save_context *pp_load_save_context = private_context;
1545 return pp_load_save_context->dest_h / 8;
1549 pp_load_save_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
1551 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1553 pp_inline_parameter->grf5.block_vertical_mask = 0xff;
1554 pp_inline_parameter->grf5.block_horizontal_mask = 0xffff;
1555 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16;
1556 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 8;
1562 pp_plx_load_save_plx_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1563 const struct i965_surface *src_surface,
1564 const VARectangle *src_rect,
1565 struct i965_surface *dst_surface,
1566 const VARectangle *dst_rect,
1569 struct pp_load_save_context *pp_load_save_context = (struct pp_load_save_context *)&pp_context->private_context;
1570 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1571 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1572 int width[3], height[3], pitch[3], offset[3];
1575 /* source surface */
1576 pp_set_media_rw_message_surface(ctx, pp_context, src_surface, 1, 0,
1577 width, height, pitch, offset);
1579 /* destination surface */
1580 pp_set_media_rw_message_surface(ctx, pp_context, dst_surface, 7, 1,
1581 width, height, pitch, offset);
1583 /* private function & data */
1584 pp_context->pp_x_steps = pp_load_save_x_steps;
1585 pp_context->pp_y_steps = pp_load_save_y_steps;
1586 pp_context->pp_set_block_parameter = pp_load_save_set_block_parameter;
1587 pp_load_save_context->dest_h = ALIGN(height[Y], 16);
1588 pp_load_save_context->dest_w = ALIGN(width[Y], 16);
1590 pp_inline_parameter->grf5.block_count_x = ALIGN(width[Y], 16) / 16; /* 1 x N */
1591 pp_inline_parameter->grf5.number_blocks = ALIGN(width[Y], 16) / 16;
1593 pp_static_parameter->grf3.horizontal_origin_offset = src_rect->x;
1594 pp_static_parameter->grf3.vertical_origin_offset = src_rect->y;
1596 // update u/v offset for packed yuv
1597 i965_update_src_surface_uv_offset (ctx, pp_context, src_surface);
1598 i965_update_dst_surface_uv_offset (ctx, pp_context, dst_surface);
1600 dst_surface->flags = src_surface->flags;
1602 return VA_STATUS_SUCCESS;
1606 pp_scaling_x_steps(void *private_context)
1612 pp_scaling_y_steps(void *private_context)
1614 struct pp_scaling_context *pp_scaling_context = private_context;
1616 return pp_scaling_context->dest_h / 8;
1620 pp_scaling_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
1622 struct pp_scaling_context *pp_scaling_context = (struct pp_scaling_context *)&pp_context->private_context;
1623 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1624 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1625 float src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1626 float src_y_steping = pp_static_parameter->grf1.r1_6.normalized_video_y_scaling_step;
1628 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin = src_x_steping * x * 16 + pp_scaling_context->src_normalized_x;
1629 pp_inline_parameter->grf5.source_surface_block_normalized_vertical_origin = src_y_steping * y * 8 + pp_scaling_context->src_normalized_y;
1630 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16 + pp_scaling_context->dest_x;
1631 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 8 + pp_scaling_context->dest_y;
1637 pp_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1638 const struct i965_surface *src_surface,
1639 const VARectangle *src_rect,
1640 struct i965_surface *dst_surface,
1641 const VARectangle *dst_rect,
1644 struct i965_driver_data *i965 = i965_driver_data(ctx);
1645 struct pp_scaling_context *pp_scaling_context = (struct pp_scaling_context *)&pp_context->private_context;
1646 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1647 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1648 struct object_surface *obj_surface;
1649 struct i965_sampler_state *sampler_state;
1650 int in_w, in_h, in_wpitch, in_hpitch;
1651 int out_w, out_h, out_wpitch, out_hpitch;
1653 /* source surface */
1654 obj_surface = SURFACE(src_surface->id);
1655 in_w = obj_surface->orig_width;
1656 in_h = obj_surface->orig_height;
1657 in_wpitch = obj_surface->width;
1658 in_hpitch = obj_surface->height;
1660 /* source Y surface index 1 */
1661 i965_pp_set_surface_state(ctx, pp_context,
1663 in_w, in_h, in_wpitch, I965_SURFACEFORMAT_R8_UNORM,
1666 /* source UV surface index 2 */
1667 i965_pp_set_surface_state(ctx, pp_context,
1668 obj_surface->bo, in_wpitch * in_hpitch,
1669 in_w / 2, in_h / 2, in_wpitch, I965_SURFACEFORMAT_R8G8_UNORM,
1672 /* destination surface */
1673 obj_surface = SURFACE(dst_surface->id);
1674 out_w = obj_surface->orig_width;
1675 out_h = obj_surface->orig_height;
1676 out_wpitch = obj_surface->width;
1677 out_hpitch = obj_surface->height;
1679 /* destination Y surface index 7 */
1680 i965_pp_set_surface_state(ctx, pp_context,
1682 out_w / 4, out_h, out_wpitch, I965_SURFACEFORMAT_R8_UNORM,
1685 /* destination UV surface index 8 */
1686 i965_pp_set_surface_state(ctx, pp_context,
1687 obj_surface->bo, out_wpitch * out_hpitch,
1688 out_w / 4, out_h / 2, out_wpitch, I965_SURFACEFORMAT_R8G8_UNORM,
1692 dri_bo_map(pp_context->sampler_state_table.bo, True);
1693 assert(pp_context->sampler_state_table.bo->virtual);
1694 sampler_state = pp_context->sampler_state_table.bo->virtual;
1696 /* SIMD16 Y index 1 */
1697 sampler_state[1].ss0.min_filter = I965_MAPFILTER_LINEAR;
1698 sampler_state[1].ss0.mag_filter = I965_MAPFILTER_LINEAR;
1699 sampler_state[1].ss1.r_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1700 sampler_state[1].ss1.s_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1701 sampler_state[1].ss1.t_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1703 /* SIMD16 UV index 2 */
1704 sampler_state[2].ss0.min_filter = I965_MAPFILTER_LINEAR;
1705 sampler_state[2].ss0.mag_filter = I965_MAPFILTER_LINEAR;
1706 sampler_state[2].ss1.r_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1707 sampler_state[2].ss1.s_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1708 sampler_state[2].ss1.t_wrap_mode = I965_TEXCOORDMODE_CLAMP;
1710 dri_bo_unmap(pp_context->sampler_state_table.bo);
1712 /* private function & data */
1713 pp_context->pp_x_steps = pp_scaling_x_steps;
1714 pp_context->pp_y_steps = pp_scaling_y_steps;
1715 pp_context->pp_set_block_parameter = pp_scaling_set_block_parameter;
1717 pp_scaling_context->dest_x = dst_rect->x;
1718 pp_scaling_context->dest_y = dst_rect->y;
1719 pp_scaling_context->dest_w = ALIGN(dst_rect->width, 16);
1720 pp_scaling_context->dest_h = ALIGN(dst_rect->height, 16);
1721 pp_scaling_context->src_normalized_x = (float)src_rect->x / in_w;
1722 pp_scaling_context->src_normalized_y = (float)src_rect->y / in_h;
1724 pp_static_parameter->grf1.r1_6.normalized_video_y_scaling_step = (float) src_rect->height / in_h / dst_rect->height;
1726 pp_inline_parameter->grf5.normalized_video_x_scaling_step = (float) src_rect->width / in_w / dst_rect->width;
1727 pp_inline_parameter->grf5.block_count_x = pp_scaling_context->dest_w / 16; /* 1 x N */
1728 pp_inline_parameter->grf5.number_blocks = pp_scaling_context->dest_w / 16;
1729 pp_inline_parameter->grf5.block_vertical_mask = 0xff;
1730 pp_inline_parameter->grf5.block_horizontal_mask = 0xffff;
1732 dst_surface->flags = src_surface->flags;
1734 return VA_STATUS_SUCCESS;
1738 pp_avs_x_steps(void *private_context)
1740 struct pp_avs_context *pp_avs_context = private_context;
1742 return pp_avs_context->dest_w / 16;
1746 pp_avs_y_steps(void *private_context)
1752 pp_avs_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
1754 struct pp_avs_context *pp_avs_context = (struct pp_avs_context *)&pp_context->private_context;
1755 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1756 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1757 float src_x_steping, src_y_steping, video_step_delta;
1758 int tmp_w = ALIGN(pp_avs_context->dest_h * pp_avs_context->src_w / pp_avs_context->src_h, 16);
1760 if (pp_static_parameter->grf4.r4_2.avs.nlas == 0) {
1761 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1762 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin = src_x_steping * x * 16 + pp_avs_context->src_normalized_x;
1763 } else if (tmp_w >= pp_avs_context->dest_w) {
1764 pp_inline_parameter->grf5.normalized_video_x_scaling_step = 1.0 / tmp_w;
1765 pp_inline_parameter->grf6.video_step_delta = 0;
1768 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin = (float)(tmp_w - pp_avs_context->dest_w) / tmp_w / 2 +
1769 pp_avs_context->src_normalized_x;
1771 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1772 video_step_delta = pp_inline_parameter->grf6.video_step_delta;
1773 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin += src_x_steping * 16 +
1774 16 * 15 * video_step_delta / 2;
1777 int n0, n1, n2, nls_left, nls_right;
1778 int factor_a = 5, factor_b = 4;
1781 n0 = (pp_avs_context->dest_w - tmp_w) / (16 * 2);
1782 n1 = (pp_avs_context->dest_w - tmp_w) / 16 - n0;
1783 n2 = tmp_w / (16 * factor_a);
1785 nls_right = n1 + n2;
1786 f = (float) n2 * 16 / tmp_w;
1789 pp_inline_parameter->grf6.video_step_delta = 0.0;
1792 pp_inline_parameter->grf5.normalized_video_x_scaling_step = 1.0 / pp_avs_context->dest_w;
1793 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin = pp_avs_context->src_normalized_x;
1795 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1796 video_step_delta = pp_inline_parameter->grf6.video_step_delta;
1797 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin += src_x_steping * 16 +
1798 16 * 15 * video_step_delta / 2;
1802 /* f = a * nls_left * 16 + b * nls_left * 16 * (nls_left * 16 - 1) / 2 */
1803 float a = f / (nls_left * 16 * factor_b);
1804 float b = (f - nls_left * 16 * a) * 2 / (nls_left * 16 * (nls_left * 16 - 1));
1806 pp_inline_parameter->grf6.video_step_delta = b;
1809 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin = pp_avs_context->src_normalized_x;
1810 pp_inline_parameter->grf5.normalized_video_x_scaling_step = a;
1812 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1813 video_step_delta = pp_inline_parameter->grf6.video_step_delta;
1814 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin += src_x_steping * 16 +
1815 16 * 15 * video_step_delta / 2;
1816 pp_inline_parameter->grf5.normalized_video_x_scaling_step += 16 * b;
1818 } else if (x < (pp_avs_context->dest_w / 16 - nls_right)) {
1819 /* scale the center linearly */
1820 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1821 video_step_delta = pp_inline_parameter->grf6.video_step_delta;
1822 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin += src_x_steping * 16 +
1823 16 * 15 * video_step_delta / 2;
1824 pp_inline_parameter->grf6.video_step_delta = 0.0;
1825 pp_inline_parameter->grf5.normalized_video_x_scaling_step = 1.0 / tmp_w;
1827 float a = f / (nls_right * 16 * factor_b);
1828 float b = (f - nls_right * 16 * a) * 2 / (nls_right * 16 * (nls_right * 16 - 1));
1830 src_x_steping = pp_inline_parameter->grf5.normalized_video_x_scaling_step;
1831 video_step_delta = pp_inline_parameter->grf6.video_step_delta;
1832 pp_inline_parameter->grf5.r5_1.source_surface_block_normalized_horizontal_origin += src_x_steping * 16 +
1833 16 * 15 * video_step_delta / 2;
1834 pp_inline_parameter->grf6.video_step_delta = -b;
1836 if (x == (pp_avs_context->dest_w / 16 - nls_right))
1837 pp_inline_parameter->grf5.normalized_video_x_scaling_step = a + (nls_right * 16 - 1) * b;
1839 pp_inline_parameter->grf5.normalized_video_x_scaling_step -= b * 16;
1844 src_y_steping = pp_static_parameter->grf1.r1_6.normalized_video_y_scaling_step;
1845 pp_inline_parameter->grf5.source_surface_block_normalized_vertical_origin = src_y_steping * y * 8 + pp_avs_context->src_normalized_y;
1846 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16 + pp_avs_context->dest_x;
1847 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 8 + pp_avs_context->dest_y;
1853 pp_nv12_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
1854 const struct i965_surface *src_surface,
1855 const VARectangle *src_rect,
1856 struct i965_surface *dst_surface,
1857 const VARectangle *dst_rect,
1861 struct i965_driver_data *i965 = i965_driver_data(ctx);
1862 struct pp_avs_context *pp_avs_context = (struct pp_avs_context *)&pp_context->private_context;
1863 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
1864 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
1865 struct object_surface *obj_surface;
1866 struct i965_sampler_8x8 *sampler_8x8;
1867 struct i965_sampler_8x8_state *sampler_8x8_state;
1869 int in_w, in_h, in_wpitch, in_hpitch;
1870 int out_w, out_h, out_wpitch, out_hpitch;
1874 obj_surface = SURFACE(src_surface->id);
1875 in_w = obj_surface->orig_width;
1876 in_h = obj_surface->orig_height;
1877 in_wpitch = obj_surface->width;
1878 in_hpitch = obj_surface->height;
1880 /* source Y surface index 1 */
1881 i965_pp_set_surface2_state(ctx, pp_context,
1883 in_w, in_h, in_wpitch,
1885 SURFACE_FORMAT_Y8_UNORM, 0,
1888 /* source UV surface index 2 */
1889 i965_pp_set_surface2_state(ctx, pp_context,
1890 obj_surface->bo, in_wpitch * in_hpitch,
1891 in_w / 2, in_h / 2, in_wpitch,
1893 SURFACE_FORMAT_R8B8_UNORM, 0,
1896 /* destination surface */
1897 obj_surface = SURFACE(dst_surface->id);
1898 out_w = obj_surface->orig_width;
1899 out_h = obj_surface->orig_height;
1900 out_wpitch = obj_surface->width;
1901 out_hpitch = obj_surface->height;
1902 assert(out_w <= out_wpitch && out_h <= out_hpitch);
1904 /* destination Y surface index 7 */
1905 i965_pp_set_surface_state(ctx, pp_context,
1907 out_w / 4, out_h, out_wpitch, I965_SURFACEFORMAT_R8_UNORM,
1910 /* destination UV surface index 8 */
1911 i965_pp_set_surface_state(ctx, pp_context,
1912 obj_surface->bo, out_wpitch * out_hpitch,
1913 out_w / 4, out_h / 2, out_wpitch, I965_SURFACEFORMAT_R8G8_UNORM,
1916 /* sampler 8x8 state */
1917 dri_bo_map(pp_context->sampler_state_table.bo_8x8, True);
1918 assert(pp_context->sampler_state_table.bo_8x8->virtual);
1919 assert(sizeof(*sampler_8x8_state) == sizeof(int) * 138);
1920 sampler_8x8_state = pp_context->sampler_state_table.bo_8x8->virtual;
1921 memset(sampler_8x8_state, 0, sizeof(*sampler_8x8_state));
1923 for (i = 0; i < 17; i++) {
1924 /* for Y channel, currently ignore */
1925 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c0 = 0x00;
1926 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c1 = 0x00;
1927 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c2 = 0x08;
1928 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c3 = 0x18;
1929 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c4 = 0x18;
1930 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c5 = 0x08;
1931 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c6 = 0x00;
1932 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c7 = 0x00;
1933 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c0 = 0x00;
1934 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c1 = 0x00;
1935 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c2 = 0x10;
1936 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c3 = 0x10;
1937 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c4 = 0x10;
1938 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c5 = 0x10;
1939 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c6 = 0x00;
1940 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c7 = 0x00;
1941 /* for U/V channel, 0.25 */
1942 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c0 = 0x0;
1943 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c1 = 0x0;
1944 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c2 = 0x10;
1945 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c3 = 0x10;
1946 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c4 = 0x10;
1947 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c5 = 0x10;
1948 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c6 = 0x0;
1949 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c7 = 0x0;
1950 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c0 = 0x0;
1951 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c1 = 0x0;
1952 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c2 = 0x10;
1953 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c3 = 0x10;
1954 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c4 = 0x10;
1955 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c5 = 0x10;
1956 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c6 = 0x0;
1957 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c7 = 0x0;
1960 sampler_8x8_state->dw136.default_sharpness_level = 0;
1961 sampler_8x8_state->dw137.adaptive_filter_for_all_channel = 1;
1962 sampler_8x8_state->dw137.bypass_y_adaptive_filtering = 1;
1963 sampler_8x8_state->dw137.bypass_x_adaptive_filtering = 1;
1964 dri_bo_unmap(pp_context->sampler_state_table.bo_8x8);
1967 dri_bo_map(pp_context->sampler_state_table.bo, True);
1968 assert(pp_context->sampler_state_table.bo->virtual);
1969 assert(sizeof(*sampler_8x8) == sizeof(int) * 16);
1970 sampler_8x8 = pp_context->sampler_state_table.bo->virtual;
1972 /* sample_8x8 Y index 1 */
1974 memset(&sampler_8x8[index], 0, sizeof(*sampler_8x8));
1975 sampler_8x8[index].dw0.avs_filter_type = AVS_FILTER_ADAPTIVE_8_TAP;
1976 sampler_8x8[index].dw0.ief_bypass = 1;
1977 sampler_8x8[index].dw0.ief_filter_type = IEF_FILTER_DETAIL;
1978 sampler_8x8[index].dw0.ief_filter_size = IEF_FILTER_SIZE_5X5;
1979 sampler_8x8[index].dw1.sampler_8x8_state_pointer = pp_context->sampler_state_table.bo_8x8->offset >> 5;
1980 sampler_8x8[index].dw2.global_noise_estimation = 22;
1981 sampler_8x8[index].dw2.strong_edge_threshold = 8;
1982 sampler_8x8[index].dw2.weak_edge_threshold = 1;
1983 sampler_8x8[index].dw3.strong_edge_weight = 7;
1984 sampler_8x8[index].dw3.regular_weight = 2;
1985 sampler_8x8[index].dw3.non_edge_weight = 0;
1986 sampler_8x8[index].dw3.gain_factor = 40;
1987 sampler_8x8[index].dw4.steepness_boost = 0;
1988 sampler_8x8[index].dw4.steepness_threshold = 0;
1989 sampler_8x8[index].dw4.mr_boost = 0;
1990 sampler_8x8[index].dw4.mr_threshold = 5;
1991 sampler_8x8[index].dw5.pwl1_point_1 = 4;
1992 sampler_8x8[index].dw5.pwl1_point_2 = 12;
1993 sampler_8x8[index].dw5.pwl1_point_3 = 16;
1994 sampler_8x8[index].dw5.pwl1_point_4 = 26;
1995 sampler_8x8[index].dw6.pwl1_point_5 = 40;
1996 sampler_8x8[index].dw6.pwl1_point_6 = 160;
1997 sampler_8x8[index].dw6.pwl1_r3_bias_0 = 127;
1998 sampler_8x8[index].dw6.pwl1_r3_bias_1 = 98;
1999 sampler_8x8[index].dw7.pwl1_r3_bias_2 = 88;
2000 sampler_8x8[index].dw7.pwl1_r3_bias_3 = 64;
2001 sampler_8x8[index].dw7.pwl1_r3_bias_4 = 44;
2002 sampler_8x8[index].dw7.pwl1_r3_bias_5 = 0;
2003 sampler_8x8[index].dw8.pwl1_r3_bias_6 = 0;
2004 sampler_8x8[index].dw8.pwl1_r5_bias_0 = 3;
2005 sampler_8x8[index].dw8.pwl1_r5_bias_1 = 32;
2006 sampler_8x8[index].dw8.pwl1_r5_bias_2 = 32;
2007 sampler_8x8[index].dw9.pwl1_r5_bias_3 = 58;
2008 sampler_8x8[index].dw9.pwl1_r5_bias_4 = 100;
2009 sampler_8x8[index].dw9.pwl1_r5_bias_5 = 108;
2010 sampler_8x8[index].dw9.pwl1_r5_bias_6 = 88;
2011 sampler_8x8[index].dw10.pwl1_r3_slope_0 = -116;
2012 sampler_8x8[index].dw10.pwl1_r3_slope_1 = -20;
2013 sampler_8x8[index].dw10.pwl1_r3_slope_2 = -96;
2014 sampler_8x8[index].dw10.pwl1_r3_slope_3 = -32;
2015 sampler_8x8[index].dw11.pwl1_r3_slope_4 = -50;
2016 sampler_8x8[index].dw11.pwl1_r3_slope_5 = 0;
2017 sampler_8x8[index].dw11.pwl1_r3_slope_6 = 0;
2018 sampler_8x8[index].dw11.pwl1_r5_slope_0 = 116;
2019 sampler_8x8[index].dw12.pwl1_r5_slope_1 = 0;
2020 sampler_8x8[index].dw12.pwl1_r5_slope_2 = 114;
2021 sampler_8x8[index].dw12.pwl1_r5_slope_3 = 67;
2022 sampler_8x8[index].dw12.pwl1_r5_slope_4 = 9;
2023 sampler_8x8[index].dw13.pwl1_r5_slope_5 = -3;
2024 sampler_8x8[index].dw13.pwl1_r5_slope_6 = -15;
2025 sampler_8x8[index].dw13.limiter_boost = 0;
2026 sampler_8x8[index].dw13.minimum_limiter = 10;
2027 sampler_8x8[index].dw13.maximum_limiter = 11;
2028 sampler_8x8[index].dw14.clip_limiter = 130;
2029 dri_bo_emit_reloc(pp_context->sampler_state_table.bo,
2030 I915_GEM_DOMAIN_RENDER,
2033 sizeof(*sampler_8x8) * index + offsetof(struct i965_sampler_8x8, dw1),
2034 pp_context->sampler_state_table.bo_8x8);
2036 /* sample_8x8 UV index 2 */
2038 memset(&sampler_8x8[index], 0, sizeof(*sampler_8x8));
2039 sampler_8x8[index].dw0.avs_filter_type = AVS_FILTER_ADAPTIVE_8_TAP;
2040 sampler_8x8[index].dw0.ief_bypass = 1;
2041 sampler_8x8[index].dw0.ief_filter_type = IEF_FILTER_DETAIL;
2042 sampler_8x8[index].dw0.ief_filter_size = IEF_FILTER_SIZE_5X5;
2043 sampler_8x8[index].dw1.sampler_8x8_state_pointer = pp_context->sampler_state_table.bo_8x8->offset >> 5;
2044 sampler_8x8[index].dw2.global_noise_estimation = 22;
2045 sampler_8x8[index].dw2.strong_edge_threshold = 8;
2046 sampler_8x8[index].dw2.weak_edge_threshold = 1;
2047 sampler_8x8[index].dw3.strong_edge_weight = 7;
2048 sampler_8x8[index].dw3.regular_weight = 2;
2049 sampler_8x8[index].dw3.non_edge_weight = 0;
2050 sampler_8x8[index].dw3.gain_factor = 40;
2051 sampler_8x8[index].dw4.steepness_boost = 0;
2052 sampler_8x8[index].dw4.steepness_threshold = 0;
2053 sampler_8x8[index].dw4.mr_boost = 0;
2054 sampler_8x8[index].dw4.mr_threshold = 5;
2055 sampler_8x8[index].dw5.pwl1_point_1 = 4;
2056 sampler_8x8[index].dw5.pwl1_point_2 = 12;
2057 sampler_8x8[index].dw5.pwl1_point_3 = 16;
2058 sampler_8x8[index].dw5.pwl1_point_4 = 26;
2059 sampler_8x8[index].dw6.pwl1_point_5 = 40;
2060 sampler_8x8[index].dw6.pwl1_point_6 = 160;
2061 sampler_8x8[index].dw6.pwl1_r3_bias_0 = 127;
2062 sampler_8x8[index].dw6.pwl1_r3_bias_1 = 98;
2063 sampler_8x8[index].dw7.pwl1_r3_bias_2 = 88;
2064 sampler_8x8[index].dw7.pwl1_r3_bias_3 = 64;
2065 sampler_8x8[index].dw7.pwl1_r3_bias_4 = 44;
2066 sampler_8x8[index].dw7.pwl1_r3_bias_5 = 0;
2067 sampler_8x8[index].dw8.pwl1_r3_bias_6 = 0;
2068 sampler_8x8[index].dw8.pwl1_r5_bias_0 = 3;
2069 sampler_8x8[index].dw8.pwl1_r5_bias_1 = 32;
2070 sampler_8x8[index].dw8.pwl1_r5_bias_2 = 32;
2071 sampler_8x8[index].dw9.pwl1_r5_bias_3 = 58;
2072 sampler_8x8[index].dw9.pwl1_r5_bias_4 = 100;
2073 sampler_8x8[index].dw9.pwl1_r5_bias_5 = 108;
2074 sampler_8x8[index].dw9.pwl1_r5_bias_6 = 88;
2075 sampler_8x8[index].dw10.pwl1_r3_slope_0 = -116;
2076 sampler_8x8[index].dw10.pwl1_r3_slope_1 = -20;
2077 sampler_8x8[index].dw10.pwl1_r3_slope_2 = -96;
2078 sampler_8x8[index].dw10.pwl1_r3_slope_3 = -32;
2079 sampler_8x8[index].dw11.pwl1_r3_slope_4 = -50;
2080 sampler_8x8[index].dw11.pwl1_r3_slope_5 = 0;
2081 sampler_8x8[index].dw11.pwl1_r3_slope_6 = 0;
2082 sampler_8x8[index].dw11.pwl1_r5_slope_0 = 116;
2083 sampler_8x8[index].dw12.pwl1_r5_slope_1 = 0;
2084 sampler_8x8[index].dw12.pwl1_r5_slope_2 = 114;
2085 sampler_8x8[index].dw12.pwl1_r5_slope_3 = 67;
2086 sampler_8x8[index].dw12.pwl1_r5_slope_4 = 9;
2087 sampler_8x8[index].dw13.pwl1_r5_slope_5 = -3;
2088 sampler_8x8[index].dw13.pwl1_r5_slope_6 = -15;
2089 sampler_8x8[index].dw13.limiter_boost = 0;
2090 sampler_8x8[index].dw13.minimum_limiter = 10;
2091 sampler_8x8[index].dw13.maximum_limiter = 11;
2092 sampler_8x8[index].dw14.clip_limiter = 130;
2093 dri_bo_emit_reloc(pp_context->sampler_state_table.bo,
2094 I915_GEM_DOMAIN_RENDER,
2097 sizeof(*sampler_8x8) * index + offsetof(struct i965_sampler_8x8, dw1),
2098 pp_context->sampler_state_table.bo_8x8);
2100 dri_bo_unmap(pp_context->sampler_state_table.bo);
2102 /* private function & data */
2103 pp_context->pp_x_steps = pp_avs_x_steps;
2104 pp_context->pp_y_steps = pp_avs_y_steps;
2105 pp_context->pp_set_block_parameter = pp_avs_set_block_parameter;
2107 pp_avs_context->dest_x = dst_rect->x;
2108 pp_avs_context->dest_y = dst_rect->y;
2109 pp_avs_context->dest_w = ALIGN(dst_rect->width, 16);
2110 pp_avs_context->dest_h = ALIGN(dst_rect->height, 16);
2111 pp_avs_context->src_normalized_x = (float)src_rect->x / in_w;
2112 pp_avs_context->src_normalized_y = (float)src_rect->y / in_h;
2113 pp_avs_context->src_w = src_rect->width;
2114 pp_avs_context->src_h = src_rect->height;
2116 pp_static_parameter->grf4.r4_2.avs.nlas = nlas;
2117 pp_static_parameter->grf1.r1_6.normalized_video_y_scaling_step = (float) src_rect->height / in_h / dst_rect->height;
2119 pp_inline_parameter->grf5.normalized_video_x_scaling_step = (float) src_rect->width / in_w / dst_rect->width;
2120 pp_inline_parameter->grf5.block_count_x = 1; /* M x 1 */
2121 pp_inline_parameter->grf5.number_blocks = pp_avs_context->dest_h / 8;
2122 pp_inline_parameter->grf5.block_vertical_mask = 0xff;
2123 pp_inline_parameter->grf5.block_horizontal_mask = 0xffff;
2124 pp_inline_parameter->grf6.video_step_delta = 0.0;
2126 dst_surface->flags = src_surface->flags;
2128 return VA_STATUS_SUCCESS;
2132 pp_nv12_avs_initialize_nlas(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2133 const struct i965_surface *src_surface,
2134 const VARectangle *src_rect,
2135 struct i965_surface *dst_surface,
2136 const VARectangle *dst_rect,
2139 return pp_nv12_avs_initialize(ctx, pp_context,
2149 gen6_nv12_scaling_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2150 const struct i965_surface *src_surface,
2151 const VARectangle *src_rect,
2152 struct i965_surface *dst_surface,
2153 const VARectangle *dst_rect,
2156 return pp_nv12_avs_initialize(ctx, pp_context,
2166 gen7_pp_avs_x_steps(void *private_context)
2168 struct pp_avs_context *pp_avs_context = private_context;
2170 return pp_avs_context->dest_w / 16;
2174 gen7_pp_avs_y_steps(void *private_context)
2176 struct pp_avs_context *pp_avs_context = private_context;
2178 return pp_avs_context->dest_h / 16;
2182 gen7_pp_avs_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
2184 struct pp_avs_context *pp_avs_context = (struct pp_avs_context *)&pp_context->private_context;
2185 struct gen7_pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2187 pp_inline_parameter->grf7.destination_block_horizontal_origin = x * 16 + pp_avs_context->dest_x;
2188 pp_inline_parameter->grf7.destination_block_vertical_origin = y * 16 + pp_avs_context->dest_y;
2189 pp_inline_parameter->grf7.constant_0 = 0xffffffff;
2190 pp_inline_parameter->grf7.sampler_load_main_video_x_scaling_step = 1.0 / pp_avs_context->src_w;
2195 static void gen7_update_src_surface_uv_offset(VADriverContextP ctx,
2196 struct i965_post_processing_context *pp_context,
2197 const struct i965_surface *surface)
2199 struct gen7_pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
2200 int fourcc = pp_get_surface_fourcc(ctx, surface);
2202 if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
2203 pp_static_parameter->grf2.di_destination_packed_y_component_offset = 0;
2204 pp_static_parameter->grf2.di_destination_packed_u_component_offset = 1;
2205 pp_static_parameter->grf2.di_destination_packed_v_component_offset = 3;
2210 gen7_pp_plx_avs_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2211 const struct i965_surface *src_surface,
2212 const VARectangle *src_rect,
2213 struct i965_surface *dst_surface,
2214 const VARectangle *dst_rect,
2217 struct pp_avs_context *pp_avs_context = (struct pp_avs_context *)&pp_context->private_context;
2218 struct gen7_pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
2219 struct gen7_sampler_8x8 *sampler_8x8;
2220 struct i965_sampler_8x8_state *sampler_8x8_state;
2222 int width[3], height[3], pitch[3], offset[3];
2224 /* source surface */
2225 gen7_pp_set_media_rw_message_surface(ctx, pp_context, src_surface, 0, 0,
2226 width, height, pitch, offset);
2228 /* destination surface */
2229 gen7_pp_set_media_rw_message_surface(ctx, pp_context, dst_surface, 24, 1,
2230 width, height, pitch, offset);
2232 /* sampler 8x8 state */
2233 dri_bo_map(pp_context->sampler_state_table.bo_8x8, True);
2234 assert(pp_context->sampler_state_table.bo_8x8->virtual);
2235 assert(sizeof(*sampler_8x8_state) == sizeof(int) * 138);
2236 sampler_8x8_state = pp_context->sampler_state_table.bo_8x8->virtual;
2237 memset(sampler_8x8_state, 0, sizeof(*sampler_8x8_state));
2239 for (i = 0; i < 17; i++) {
2240 /* for Y channel, currently ignore */
2241 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c0 = 0x0;
2242 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c1 = 0x0;
2243 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c2 = 0x0;
2244 sampler_8x8_state->coefficients[i].dw0.table_0x_filter_c3 = 0x0;
2245 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c4 = 0x0;
2246 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c5 = 0x0;
2247 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c6 = 0x0;
2248 sampler_8x8_state->coefficients[i].dw1.table_0x_filter_c7 = 0x0;
2249 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c0 = 0x0;
2250 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c1 = 0x0;
2251 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c2 = 0x0;
2252 sampler_8x8_state->coefficients[i].dw2.table_0y_filter_c3 = 0x0;
2253 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c4 = 0x0;
2254 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c5 = 0x0;
2255 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c6 = 0x0;
2256 sampler_8x8_state->coefficients[i].dw3.table_0y_filter_c7 = 0x0;
2257 /* for U/V channel, 0.25 */
2258 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c0 = 0x0;
2259 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c1 = 0x0;
2260 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c2 = 0x10;
2261 sampler_8x8_state->coefficients[i].dw4.table_1x_filter_c3 = 0x10;
2262 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c4 = 0x10;
2263 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c5 = 0x10;
2264 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c6 = 0x0;
2265 sampler_8x8_state->coefficients[i].dw5.table_1x_filter_c7 = 0x0;
2266 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c0 = 0x0;
2267 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c1 = 0x0;
2268 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c2 = 0x10;
2269 sampler_8x8_state->coefficients[i].dw6.table_1y_filter_c3 = 0x10;
2270 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c4 = 0x10;
2271 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c5 = 0x10;
2272 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c6 = 0x0;
2273 sampler_8x8_state->coefficients[i].dw7.table_1y_filter_c7 = 0x0;
2276 sampler_8x8_state->dw136.default_sharpness_level = 0;
2277 sampler_8x8_state->dw137.adaptive_filter_for_all_channel = 1;
2278 sampler_8x8_state->dw137.bypass_y_adaptive_filtering = 1;
2279 sampler_8x8_state->dw137.bypass_x_adaptive_filtering = 1;
2280 dri_bo_unmap(pp_context->sampler_state_table.bo_8x8);
2283 dri_bo_map(pp_context->sampler_state_table.bo, True);
2284 assert(pp_context->sampler_state_table.bo->virtual);
2285 assert(sizeof(*sampler_8x8) == sizeof(int) * 4);
2286 sampler_8x8 = pp_context->sampler_state_table.bo->virtual;
2288 /* sample_8x8 Y index 4 */
2290 memset(&sampler_8x8[index], 0, sizeof(*sampler_8x8));
2291 sampler_8x8[index].dw0.global_noise_estimation = 255;
2292 sampler_8x8[index].dw0.ief_bypass = 1;
2294 sampler_8x8[index].dw1.sampler_8x8_state_pointer = pp_context->sampler_state_table.bo_8x8->offset >> 5;
2296 sampler_8x8[index].dw2.weak_edge_threshold = 1;
2297 sampler_8x8[index].dw2.strong_edge_threshold = 8;
2298 sampler_8x8[index].dw2.r5x_coefficient = 9;
2299 sampler_8x8[index].dw2.r5cx_coefficient = 8;
2300 sampler_8x8[index].dw2.r5c_coefficient = 3;
2302 sampler_8x8[index].dw3.r3x_coefficient = 27;
2303 sampler_8x8[index].dw3.r3c_coefficient = 5;
2304 sampler_8x8[index].dw3.gain_factor = 40;
2305 sampler_8x8[index].dw3.non_edge_weight = 1;
2306 sampler_8x8[index].dw3.regular_weight = 2;
2307 sampler_8x8[index].dw3.strong_edge_weight = 7;
2308 sampler_8x8[index].dw3.ief4_smooth_enable = 0;
2310 dri_bo_emit_reloc(pp_context->sampler_state_table.bo,
2311 I915_GEM_DOMAIN_RENDER,
2314 sizeof(*sampler_8x8) * index + offsetof(struct i965_sampler_8x8, dw1),
2315 pp_context->sampler_state_table.bo_8x8);
2317 /* sample_8x8 UV index 8 */
2319 memset(&sampler_8x8[index], 0, sizeof(*sampler_8x8));
2320 sampler_8x8[index].dw0.disable_8x8_filter = 0;
2321 sampler_8x8[index].dw0.global_noise_estimation = 255;
2322 sampler_8x8[index].dw0.ief_bypass = 1;
2323 sampler_8x8[index].dw1.sampler_8x8_state_pointer = pp_context->sampler_state_table.bo_8x8->offset >> 5;
2324 sampler_8x8[index].dw2.weak_edge_threshold = 1;
2325 sampler_8x8[index].dw2.strong_edge_threshold = 8;
2326 sampler_8x8[index].dw2.r5x_coefficient = 9;
2327 sampler_8x8[index].dw2.r5cx_coefficient = 8;
2328 sampler_8x8[index].dw2.r5c_coefficient = 3;
2329 sampler_8x8[index].dw3.r3x_coefficient = 27;
2330 sampler_8x8[index].dw3.r3c_coefficient = 5;
2331 sampler_8x8[index].dw3.gain_factor = 40;
2332 sampler_8x8[index].dw3.non_edge_weight = 1;
2333 sampler_8x8[index].dw3.regular_weight = 2;
2334 sampler_8x8[index].dw3.strong_edge_weight = 7;
2335 sampler_8x8[index].dw3.ief4_smooth_enable = 0;
2337 dri_bo_emit_reloc(pp_context->sampler_state_table.bo,
2338 I915_GEM_DOMAIN_RENDER,
2341 sizeof(*sampler_8x8) * index + offsetof(struct i965_sampler_8x8, dw1),
2342 pp_context->sampler_state_table.bo_8x8);
2344 /* sampler_8x8 V, index 12 */
2346 memset(&sampler_8x8[index], 0, sizeof(*sampler_8x8));
2347 sampler_8x8[index].dw0.disable_8x8_filter = 0;
2348 sampler_8x8[index].dw0.global_noise_estimation = 255;
2349 sampler_8x8[index].dw0.ief_bypass = 1;
2350 sampler_8x8[index].dw1.sampler_8x8_state_pointer = pp_context->sampler_state_table.bo_8x8->offset >> 5;
2351 sampler_8x8[index].dw2.weak_edge_threshold = 1;
2352 sampler_8x8[index].dw2.strong_edge_threshold = 8;
2353 sampler_8x8[index].dw2.r5x_coefficient = 9;
2354 sampler_8x8[index].dw2.r5cx_coefficient = 8;
2355 sampler_8x8[index].dw2.r5c_coefficient = 3;
2356 sampler_8x8[index].dw3.r3x_coefficient = 27;
2357 sampler_8x8[index].dw3.r3c_coefficient = 5;
2358 sampler_8x8[index].dw3.gain_factor = 40;
2359 sampler_8x8[index].dw3.non_edge_weight = 1;
2360 sampler_8x8[index].dw3.regular_weight = 2;
2361 sampler_8x8[index].dw3.strong_edge_weight = 7;
2362 sampler_8x8[index].dw3.ief4_smooth_enable = 0;
2364 dri_bo_emit_reloc(pp_context->sampler_state_table.bo,
2365 I915_GEM_DOMAIN_RENDER,
2368 sizeof(*sampler_8x8) * index + offsetof(struct i965_sampler_8x8, dw1),
2369 pp_context->sampler_state_table.bo_8x8);
2371 dri_bo_unmap(pp_context->sampler_state_table.bo);
2373 /* private function & data */
2374 pp_context->pp_x_steps = gen7_pp_avs_x_steps;
2375 pp_context->pp_y_steps = gen7_pp_avs_y_steps;
2376 pp_context->pp_set_block_parameter = gen7_pp_avs_set_block_parameter;
2378 pp_avs_context->dest_x = dst_rect->x;
2379 pp_avs_context->dest_y = dst_rect->y;
2380 pp_avs_context->dest_w = ALIGN(dst_rect->width, 16);
2381 pp_avs_context->dest_h = ALIGN(dst_rect->height, 16);
2382 pp_avs_context->src_w = src_rect->width;
2383 pp_avs_context->src_h = src_rect->height;
2385 int dw = (pp_avs_context->src_w - 1) / 16 + 1;
2386 dw = MAX(dw, pp_avs_context->dest_w);
2388 pp_static_parameter->grf1.pointer_to_inline_parameter = 7;
2389 pp_static_parameter->grf3.sampler_load_horizontal_scaling_step_ratio = (float) pp_avs_context->src_w / dw;
2390 pp_static_parameter->grf4.sampler_load_vertical_scaling_step = (float) 1.0 / pp_avs_context->dest_h;
2391 pp_static_parameter->grf5.sampler_load_vertical_frame_origin = -(float)pp_avs_context->dest_y / pp_avs_context->dest_h;
2392 pp_static_parameter->grf6.sampler_load_horizontal_frame_origin = -(float)pp_avs_context->dest_x / dw;
2394 gen7_update_src_surface_uv_offset(ctx, pp_context, dst_surface);
2396 dst_surface->flags = src_surface->flags;
2398 return VA_STATUS_SUCCESS;
2402 pp_dndi_x_steps(void *private_context)
2408 pp_dndi_y_steps(void *private_context)
2410 struct pp_dndi_context *pp_dndi_context = private_context;
2412 return pp_dndi_context->dest_h / 4;
2416 pp_dndi_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
2418 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2420 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16;
2421 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 4;
2427 pp_nv12_dndi_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2428 const struct i965_surface *src_surface,
2429 const VARectangle *src_rect,
2430 struct i965_surface *dst_surface,
2431 const VARectangle *dst_rect,
2434 struct i965_driver_data *i965 = i965_driver_data(ctx);
2435 struct pp_dndi_context *pp_dndi_context = (struct pp_dndi_context *)&pp_context->private_context;
2436 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2437 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
2438 struct object_surface *obj_surface;
2439 struct i965_sampler_dndi *sampler_dndi;
2443 int dndi_top_first = 1;
2445 if (src_surface->flags == I965_SURFACE_FLAG_FRAME)
2446 return VA_STATUS_ERROR_FLAG_NOT_SUPPORTED;
2448 if (src_surface->flags == I965_SURFACE_FLAG_TOP_FIELD_FIRST)
2454 obj_surface = SURFACE(src_surface->id);
2455 orig_w = obj_surface->orig_width;
2456 orig_h = obj_surface->orig_height;
2457 w = obj_surface->width;
2458 h = obj_surface->height;
2460 if (pp_context->stmm.bo == NULL) {
2461 pp_context->stmm.bo = dri_bo_alloc(i965->intel.bufmgr,
2465 assert(pp_context->stmm.bo);
2468 /* source UV surface index 2 */
2469 i965_pp_set_surface_state(ctx, pp_context,
2470 obj_surface->bo, w * h,
2471 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2474 /* source YUV surface index 4 */
2475 i965_pp_set_surface2_state(ctx, pp_context,
2479 SURFACE_FORMAT_PLANAR_420_8, 1,
2482 /* source STMM surface index 20 */
2483 i965_pp_set_surface_state(ctx, pp_context,
2484 pp_context->stmm.bo, 0,
2485 orig_w, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2488 /* destination surface */
2489 obj_surface = SURFACE(dst_surface->id);
2490 orig_w = obj_surface->orig_width;
2491 orig_h = obj_surface->orig_height;
2492 w = obj_surface->width;
2493 h = obj_surface->height;
2495 /* destination Y surface index 7 */
2496 i965_pp_set_surface_state(ctx, pp_context,
2498 orig_w / 4, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2501 /* destination UV surface index 8 */
2502 i965_pp_set_surface_state(ctx, pp_context,
2503 obj_surface->bo, w * h,
2504 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2507 dri_bo_map(pp_context->sampler_state_table.bo, True);
2508 assert(pp_context->sampler_state_table.bo->virtual);
2509 assert(sizeof(*sampler_dndi) == sizeof(int) * 8);
2510 sampler_dndi = pp_context->sampler_state_table.bo->virtual;
2512 /* sample dndi index 1 */
2514 sampler_dndi[index].dw0.denoise_asd_threshold = 0;
2515 sampler_dndi[index].dw0.denoise_history_delta = 8; // 0-15, default is 8
2516 sampler_dndi[index].dw0.denoise_maximum_history = 128; // 128-240
2517 sampler_dndi[index].dw0.denoise_stad_threshold = 0;
2519 sampler_dndi[index].dw1.denoise_threshold_for_sum_of_complexity_measure = 64;
2520 sampler_dndi[index].dw1.denoise_moving_pixel_threshold = 4;
2521 sampler_dndi[index].dw1.stmm_c2 = 1;
2522 sampler_dndi[index].dw1.low_temporal_difference_threshold = 8;
2523 sampler_dndi[index].dw1.temporal_difference_threshold = 16;
2525 sampler_dndi[index].dw2.block_noise_estimate_noise_threshold = 15; // 0-31
2526 sampler_dndi[index].dw2.block_noise_estimate_edge_threshold = 7; // 0-15
2527 sampler_dndi[index].dw2.denoise_edge_threshold = 7; // 0-15
2528 sampler_dndi[index].dw2.good_neighbor_threshold = 4; // 0-63
2530 sampler_dndi[index].dw3.maximum_stmm = 128;
2531 sampler_dndi[index].dw3.multipler_for_vecm = 2;
2532 sampler_dndi[index].dw3.blending_constant_across_time_for_small_values_of_stmm = 0;
2533 sampler_dndi[index].dw3.blending_constant_across_time_for_large_values_of_stmm = 64;
2534 sampler_dndi[index].dw3.stmm_blending_constant_select = 0;
2536 sampler_dndi[index].dw4.sdi_delta = 8;
2537 sampler_dndi[index].dw4.sdi_threshold = 128;
2538 sampler_dndi[index].dw4.stmm_output_shift = 7; // stmm_max - stmm_min = 2 ^ stmm_output_shift
2539 sampler_dndi[index].dw4.stmm_shift_up = 0;
2540 sampler_dndi[index].dw4.stmm_shift_down = 0;
2541 sampler_dndi[index].dw4.minimum_stmm = 0;
2543 sampler_dndi[index].dw5.fmd_temporal_difference_threshold = 8;
2544 sampler_dndi[index].dw5.sdi_fallback_mode_2_constant = 32;
2545 sampler_dndi[index].dw5.sdi_fallback_mode_1_t2_constant = 64;
2546 sampler_dndi[index].dw5.sdi_fallback_mode_1_t1_constant = 32;
2548 sampler_dndi[index].dw6.dn_enable = 1;
2549 sampler_dndi[index].dw6.di_enable = 1;
2550 sampler_dndi[index].dw6.di_partial = 0;
2551 sampler_dndi[index].dw6.dndi_top_first = dndi_top_first;
2552 sampler_dndi[index].dw6.dndi_stream_id = 0;
2553 sampler_dndi[index].dw6.dndi_first_frame = 1;
2554 sampler_dndi[index].dw6.progressive_dn = 0;
2555 sampler_dndi[index].dw6.fmd_tear_threshold = 63;
2556 sampler_dndi[index].dw6.fmd2_vertical_difference_threshold = 32;
2557 sampler_dndi[index].dw6.fmd1_vertical_difference_threshold = 32;
2559 sampler_dndi[index].dw7.fmd_for_1st_field_of_current_frame = 0;
2560 sampler_dndi[index].dw7.fmd_for_2nd_field_of_previous_frame = 0;
2561 sampler_dndi[index].dw7.vdi_walker_enable = 0;
2562 sampler_dndi[index].dw7.column_width_minus1 = 0;
2564 dri_bo_unmap(pp_context->sampler_state_table.bo);
2566 /* private function & data */
2567 pp_context->pp_x_steps = pp_dndi_x_steps;
2568 pp_context->pp_y_steps = pp_dndi_y_steps;
2569 pp_context->pp_set_block_parameter = pp_dndi_set_block_parameter;
2571 pp_static_parameter->grf1.statistics_surface_picth = w / 2;
2572 pp_static_parameter->grf1.r1_6.di.top_field_first = dndi_top_first;
2573 pp_static_parameter->grf4.r4_2.di.motion_history_coefficient_m2 = 0;
2574 pp_static_parameter->grf4.r4_2.di.motion_history_coefficient_m1 = 0;
2576 pp_inline_parameter->grf5.block_count_x = w / 16; /* 1 x N */
2577 pp_inline_parameter->grf5.number_blocks = w / 16;
2578 pp_inline_parameter->grf5.block_vertical_mask = 0xff;
2579 pp_inline_parameter->grf5.block_horizontal_mask = 0xffff;
2581 pp_dndi_context->dest_w = w;
2582 pp_dndi_context->dest_h = h;
2584 dst_surface->flags = I965_SURFACE_FLAG_FRAME;
2586 return VA_STATUS_SUCCESS;
2590 pp_dn_x_steps(void *private_context)
2596 pp_dn_y_steps(void *private_context)
2598 struct pp_dn_context *pp_dn_context = private_context;
2600 return pp_dn_context->dest_h / 8;
2604 pp_dn_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
2606 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2608 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16;
2609 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 8;
2615 pp_nv12_dn_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2616 const struct i965_surface *src_surface,
2617 const VARectangle *src_rect,
2618 struct i965_surface *dst_surface,
2619 const VARectangle *dst_rect,
2622 struct i965_driver_data *i965 = i965_driver_data(ctx);
2623 struct pp_dn_context *pp_dn_context = (struct pp_dn_context *)&pp_context->private_context;
2624 struct object_surface *obj_surface;
2625 struct i965_sampler_dndi *sampler_dndi;
2626 struct pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
2627 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2628 VAProcFilterParameterBuffer *dn_filter_param = filter_param; /* FIXME: parameter */
2632 int dn_strength = 15;
2633 int dndi_top_first = 1;
2634 int dn_progressive = 0;
2636 if (src_surface->flags == I965_SURFACE_FLAG_FRAME) {
2639 } else if (src_surface->flags == I965_SURFACE_FLAG_TOP_FIELD_FIRST) {
2647 if (dn_filter_param) {
2648 float value = dn_filter_param->value;
2656 dn_strength = (int)(value * 31.0F);
2660 obj_surface = SURFACE(src_surface->id);
2661 orig_w = obj_surface->orig_width;
2662 orig_h = obj_surface->orig_height;
2663 w = obj_surface->width;
2664 h = obj_surface->height;
2666 if (pp_context->stmm.bo == NULL) {
2667 pp_context->stmm.bo = dri_bo_alloc(i965->intel.bufmgr,
2671 assert(pp_context->stmm.bo);
2674 /* source UV surface index 2 */
2675 i965_pp_set_surface_state(ctx, pp_context,
2676 obj_surface->bo, w * h,
2677 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2680 /* source YUV surface index 4 */
2681 i965_pp_set_surface2_state(ctx, pp_context,
2685 SURFACE_FORMAT_PLANAR_420_8, 1,
2688 /* source STMM surface index 20 */
2689 i965_pp_set_surface_state(ctx, pp_context,
2690 pp_context->stmm.bo, 0,
2691 orig_w, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2694 /* destination surface */
2695 obj_surface = SURFACE(dst_surface->id);
2696 orig_w = obj_surface->orig_width;
2697 orig_h = obj_surface->orig_height;
2698 w = obj_surface->width;
2699 h = obj_surface->height;
2701 /* destination Y surface index 7 */
2702 i965_pp_set_surface_state(ctx, pp_context,
2704 orig_w / 4, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2707 /* destination UV surface index 8 */
2708 i965_pp_set_surface_state(ctx, pp_context,
2709 obj_surface->bo, w * h,
2710 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2713 dri_bo_map(pp_context->sampler_state_table.bo, True);
2714 assert(pp_context->sampler_state_table.bo->virtual);
2715 assert(sizeof(*sampler_dndi) == sizeof(int) * 8);
2716 sampler_dndi = pp_context->sampler_state_table.bo->virtual;
2718 /* sample dndi index 1 */
2720 sampler_dndi[index].dw0.denoise_asd_threshold = 0;
2721 sampler_dndi[index].dw0.denoise_history_delta = 8; // 0-15, default is 8
2722 sampler_dndi[index].dw0.denoise_maximum_history = 128; // 128-240
2723 sampler_dndi[index].dw0.denoise_stad_threshold = 0;
2725 sampler_dndi[index].dw1.denoise_threshold_for_sum_of_complexity_measure = 64;
2726 sampler_dndi[index].dw1.denoise_moving_pixel_threshold = 0;
2727 sampler_dndi[index].dw1.stmm_c2 = 0;
2728 sampler_dndi[index].dw1.low_temporal_difference_threshold = 8;
2729 sampler_dndi[index].dw1.temporal_difference_threshold = 16;
2731 sampler_dndi[index].dw2.block_noise_estimate_noise_threshold = dn_strength; // 0-31
2732 sampler_dndi[index].dw2.block_noise_estimate_edge_threshold = 7; // 0-15
2733 sampler_dndi[index].dw2.denoise_edge_threshold = 7; // 0-15
2734 sampler_dndi[index].dw2.good_neighbor_threshold = 7; // 0-63
2736 sampler_dndi[index].dw3.maximum_stmm = 128;
2737 sampler_dndi[index].dw3.multipler_for_vecm = 2;
2738 sampler_dndi[index].dw3.blending_constant_across_time_for_small_values_of_stmm = 0;
2739 sampler_dndi[index].dw3.blending_constant_across_time_for_large_values_of_stmm = 64;
2740 sampler_dndi[index].dw3.stmm_blending_constant_select = 0;
2742 sampler_dndi[index].dw4.sdi_delta = 8;
2743 sampler_dndi[index].dw4.sdi_threshold = 128;
2744 sampler_dndi[index].dw4.stmm_output_shift = 7; // stmm_max - stmm_min = 2 ^ stmm_output_shift
2745 sampler_dndi[index].dw4.stmm_shift_up = 0;
2746 sampler_dndi[index].dw4.stmm_shift_down = 0;
2747 sampler_dndi[index].dw4.minimum_stmm = 0;
2749 sampler_dndi[index].dw5.fmd_temporal_difference_threshold = 0;
2750 sampler_dndi[index].dw5.sdi_fallback_mode_2_constant = 0;
2751 sampler_dndi[index].dw5.sdi_fallback_mode_1_t2_constant = 0;
2752 sampler_dndi[index].dw5.sdi_fallback_mode_1_t1_constant = 0;
2754 sampler_dndi[index].dw6.dn_enable = 1;
2755 sampler_dndi[index].dw6.di_enable = 0;
2756 sampler_dndi[index].dw6.di_partial = 0;
2757 sampler_dndi[index].dw6.dndi_top_first = dndi_top_first;
2758 sampler_dndi[index].dw6.dndi_stream_id = 1;
2759 sampler_dndi[index].dw6.dndi_first_frame = 1;
2760 sampler_dndi[index].dw6.progressive_dn = dn_progressive;
2761 sampler_dndi[index].dw6.fmd_tear_threshold = 32;
2762 sampler_dndi[index].dw6.fmd2_vertical_difference_threshold = 32;
2763 sampler_dndi[index].dw6.fmd1_vertical_difference_threshold = 32;
2765 sampler_dndi[index].dw7.fmd_for_1st_field_of_current_frame = 2;
2766 sampler_dndi[index].dw7.fmd_for_2nd_field_of_previous_frame = 1;
2767 sampler_dndi[index].dw7.vdi_walker_enable = 0;
2768 sampler_dndi[index].dw7.column_width_minus1 = w / 16;
2770 dri_bo_unmap(pp_context->sampler_state_table.bo);
2772 /* private function & data */
2773 pp_context->pp_x_steps = pp_dn_x_steps;
2774 pp_context->pp_y_steps = pp_dn_y_steps;
2775 pp_context->pp_set_block_parameter = pp_dn_set_block_parameter;
2777 pp_static_parameter->grf1.statistics_surface_picth = w / 2;
2778 pp_static_parameter->grf1.r1_6.di.top_field_first = 0;
2779 pp_static_parameter->grf4.r4_2.di.motion_history_coefficient_m2 = 64;
2780 pp_static_parameter->grf4.r4_2.di.motion_history_coefficient_m1 = 192;
2782 pp_inline_parameter->grf5.block_count_x = w / 16; /* 1 x N */
2783 pp_inline_parameter->grf5.number_blocks = w / 16;
2784 pp_inline_parameter->grf5.block_vertical_mask = 0xff;
2785 pp_inline_parameter->grf5.block_horizontal_mask = 0xffff;
2787 pp_dn_context->dest_w = w;
2788 pp_dn_context->dest_h = h;
2790 dst_surface->flags = src_surface->flags;
2792 return VA_STATUS_SUCCESS;
2796 gen7_pp_dndi_x_steps(void *private_context)
2798 struct pp_dndi_context *pp_dndi_context = private_context;
2800 return pp_dndi_context->dest_w / 16;
2804 gen7_pp_dndi_y_steps(void *private_context)
2806 struct pp_dndi_context *pp_dndi_context = private_context;
2808 return pp_dndi_context->dest_h / 4;
2812 gen7_pp_dndi_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
2814 struct gen7_pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
2816 pp_inline_parameter->grf7.destination_block_horizontal_origin = x * 16;
2817 pp_inline_parameter->grf7.destination_block_vertical_origin = y * 4;
2823 gen7_pp_nv12_dndi_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
2824 const struct i965_surface *src_surface,
2825 const VARectangle *src_rect,
2826 struct i965_surface *dst_surface,
2827 const VARectangle *dst_rect,
2830 struct i965_driver_data *i965 = i965_driver_data(ctx);
2831 struct pp_dndi_context *pp_dndi_context = (struct pp_dndi_context *)&pp_context->private_context;
2832 struct gen7_pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
2833 struct object_surface *obj_surface;
2834 struct gen7_sampler_dndi *sampler_dndi;
2838 int dndi_top_first = 1;
2840 if (src_surface->flags == I965_SURFACE_FLAG_FRAME)
2841 return VA_STATUS_ERROR_FLAG_NOT_SUPPORTED;
2843 if (src_surface->flags == I965_SURFACE_FLAG_TOP_FIELD_FIRST)
2849 obj_surface = SURFACE(src_surface->id);
2850 orig_w = obj_surface->orig_width;
2851 orig_h = obj_surface->orig_height;
2852 w = obj_surface->width;
2853 h = obj_surface->height;
2855 if (pp_context->stmm.bo == NULL) {
2856 pp_context->stmm.bo = dri_bo_alloc(i965->intel.bufmgr,
2860 assert(pp_context->stmm.bo);
2863 /* source UV surface index 1 */
2864 gen7_pp_set_surface_state(ctx, pp_context,
2865 obj_surface->bo, w * h,
2866 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2869 /* source YUV surface index 3 */
2870 gen7_pp_set_surface2_state(ctx, pp_context,
2874 SURFACE_FORMAT_PLANAR_420_8, 1,
2877 /* source (temporal reference) YUV surface index 4 */
2878 gen7_pp_set_surface2_state(ctx, pp_context,
2882 SURFACE_FORMAT_PLANAR_420_8, 1,
2885 /* STMM / History Statistics input surface, index 5 */
2886 gen7_pp_set_surface_state(ctx, pp_context,
2887 pp_context->stmm.bo, 0,
2888 orig_w, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2891 /* destination surface */
2892 obj_surface = SURFACE(dst_surface->id);
2893 orig_w = obj_surface->orig_width;
2894 orig_h = obj_surface->orig_height;
2895 w = obj_surface->width;
2896 h = obj_surface->height;
2898 /* destination(Previous frame) Y surface index 27 */
2899 gen7_pp_set_surface_state(ctx, pp_context,
2901 orig_w / 4, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2904 /* destination(Previous frame) UV surface index 28 */
2905 gen7_pp_set_surface_state(ctx, pp_context,
2906 obj_surface->bo, w * h,
2907 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2910 /* destination(Current frame) Y surface index 30 */
2911 gen7_pp_set_surface_state(ctx, pp_context,
2913 orig_w / 4, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2916 /* destination(Current frame) UV surface index 31 */
2917 gen7_pp_set_surface_state(ctx, pp_context,
2918 obj_surface->bo, w * h,
2919 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
2922 /* STMM output surface, index 33 */
2923 gen7_pp_set_surface_state(ctx, pp_context,
2924 pp_context->stmm.bo, 0,
2925 orig_w, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
2930 dri_bo_map(pp_context->sampler_state_table.bo, True);
2931 assert(pp_context->sampler_state_table.bo->virtual);
2932 assert(sizeof(*sampler_dndi) == sizeof(int) * 8);
2933 sampler_dndi = pp_context->sampler_state_table.bo->virtual;
2935 /* sample dndi index 0 */
2937 sampler_dndi[index].dw0.denoise_asd_threshold = 0;
2938 sampler_dndi[index].dw0.dnmh_delt = 8;
2939 sampler_dndi[index].dw0.vdi_walker_y_stride = 0;
2940 sampler_dndi[index].dw0.vdi_walker_frame_sharing_enable = 0;
2941 sampler_dndi[index].dw0.denoise_maximum_history = 128; // 128-240
2942 sampler_dndi[index].dw0.denoise_stad_threshold = 0;
2944 sampler_dndi[index].dw1.denoise_threshold_for_sum_of_complexity_measure = 64;
2945 sampler_dndi[index].dw1.denoise_moving_pixel_threshold = 0;
2946 sampler_dndi[index].dw1.stmm_c2 = 0;
2947 sampler_dndi[index].dw1.low_temporal_difference_threshold = 8;
2948 sampler_dndi[index].dw1.temporal_difference_threshold = 16;
2950 sampler_dndi[index].dw2.block_noise_estimate_noise_threshold = 15; // 0-31
2951 sampler_dndi[index].dw2.bne_edge_th = 1;
2952 sampler_dndi[index].dw2.smooth_mv_th = 0;
2953 sampler_dndi[index].dw2.sad_tight_th = 5;
2954 sampler_dndi[index].dw2.cat_slope_minus1 = 9;
2955 sampler_dndi[index].dw2.good_neighbor_th = 4;
2957 sampler_dndi[index].dw3.maximum_stmm = 128;
2958 sampler_dndi[index].dw3.multipler_for_vecm = 2;
2959 sampler_dndi[index].dw3.blending_constant_across_time_for_small_values_of_stmm = 0;
2960 sampler_dndi[index].dw3.blending_constant_across_time_for_large_values_of_stmm = 64;
2961 sampler_dndi[index].dw3.stmm_blending_constant_select = 0;
2963 sampler_dndi[index].dw4.sdi_delta = 8;
2964 sampler_dndi[index].dw4.sdi_threshold = 128;
2965 sampler_dndi[index].dw4.stmm_output_shift = 7; // stmm_max - stmm_min = 2 ^ stmm_output_shift
2966 sampler_dndi[index].dw4.stmm_shift_up = 0;
2967 sampler_dndi[index].dw4.stmm_shift_down = 0;
2968 sampler_dndi[index].dw4.minimum_stmm = 0;
2970 sampler_dndi[index].dw5.fmd_temporal_difference_threshold = 0;
2971 sampler_dndi[index].dw5.sdi_fallback_mode_2_constant = 0;
2972 sampler_dndi[index].dw5.sdi_fallback_mode_1_t2_constant = 0;
2973 sampler_dndi[index].dw5.sdi_fallback_mode_1_t1_constant = 0;
2975 sampler_dndi[index].dw6.dn_enable = 0;
2976 sampler_dndi[index].dw6.di_enable = 1;
2977 sampler_dndi[index].dw6.di_partial = 0;
2978 sampler_dndi[index].dw6.dndi_top_first = dndi_top_first;
2979 sampler_dndi[index].dw6.dndi_stream_id = 1;
2980 sampler_dndi[index].dw6.dndi_first_frame = 1;
2981 sampler_dndi[index].dw6.progressive_dn = 0;
2982 sampler_dndi[index].dw6.mcdi_enable = 0;
2983 sampler_dndi[index].dw6.fmd_tear_threshold = 32;
2984 sampler_dndi[index].dw6.cat_th1 = 0;
2985 sampler_dndi[index].dw6.fmd2_vertical_difference_threshold = 32;
2986 sampler_dndi[index].dw6.fmd1_vertical_difference_threshold = 32;
2988 sampler_dndi[index].dw7.sad_tha = 5;
2989 sampler_dndi[index].dw7.sad_thb = 10;
2990 sampler_dndi[index].dw7.fmd_for_1st_field_of_current_frame = 0;
2991 sampler_dndi[index].dw7.mc_pixel_consistency_th = 25;
2992 sampler_dndi[index].dw7.fmd_for_2nd_field_of_previous_frame = 0;
2993 sampler_dndi[index].dw7.vdi_walker_enable = 0;
2994 sampler_dndi[index].dw7.neighborpixel_th = 10;
2995 sampler_dndi[index].dw7.column_width_minus1 = w / 16;
2997 dri_bo_unmap(pp_context->sampler_state_table.bo);
2999 /* private function & data */
3000 pp_context->pp_x_steps = gen7_pp_dndi_x_steps;
3001 pp_context->pp_y_steps = gen7_pp_dndi_y_steps;
3002 pp_context->pp_set_block_parameter = gen7_pp_dndi_set_block_parameter;
3004 pp_static_parameter->grf1.di_statistics_surface_pitch_div2 = w / 2;
3005 pp_static_parameter->grf1.di_statistics_surface_height_div4 = h / 4;
3006 pp_static_parameter->grf1.di_top_field_first = 0;
3007 pp_static_parameter->grf1.pointer_to_inline_parameter = 7;
3009 pp_static_parameter->grf2.di_destination_packed_y_component_offset = 0;
3010 pp_static_parameter->grf2.di_destination_packed_u_component_offset = 1;
3011 pp_static_parameter->grf2.di_destination_packed_v_component_offset = 3;
3013 pp_static_parameter->grf4.di_hoffset_svf_from_dvf = 0;
3014 pp_static_parameter->grf4.di_voffset_svf_from_dvf = 0;
3016 pp_dndi_context->dest_w = w;
3017 pp_dndi_context->dest_h = h;
3019 dst_surface->flags = I965_SURFACE_FLAG_FRAME;
3021 return VA_STATUS_SUCCESS;
3025 gen7_pp_dn_x_steps(void *private_context)
3031 gen7_pp_dn_y_steps(void *private_context)
3033 struct pp_dn_context *pp_dn_context = private_context;
3035 return pp_dn_context->dest_h / 4;
3039 gen7_pp_dn_set_block_parameter(struct i965_post_processing_context *pp_context, int x, int y)
3041 struct pp_inline_parameter *pp_inline_parameter = pp_context->pp_inline_parameter;
3043 pp_inline_parameter->grf5.destination_block_horizontal_origin = x * 16;
3044 pp_inline_parameter->grf5.destination_block_vertical_origin = y * 4;
3050 gen7_pp_nv12_dn_initialize(VADriverContextP ctx, struct i965_post_processing_context *pp_context,
3051 const struct i965_surface *src_surface,
3052 const VARectangle *src_rect,
3053 struct i965_surface *dst_surface,
3054 const VARectangle *dst_rect,
3057 struct i965_driver_data *i965 = i965_driver_data(ctx);
3058 struct pp_dn_context *pp_dn_context = (struct pp_dn_context *)&pp_context->private_context;
3059 struct gen7_pp_static_parameter *pp_static_parameter = pp_context->pp_static_parameter;
3060 struct object_surface *obj_surface;
3061 struct gen7_sampler_dndi *sampler_dn;
3062 VAProcFilterParameterBuffer *dn_filter_param = filter_param; /* FIXME: parameter */
3066 int dn_strength = 15;
3067 int dndi_top_first = 1;
3068 int dn_progressive = 0;
3070 if (src_surface->flags == I965_SURFACE_FLAG_FRAME) {
3073 } else if (src_surface->flags == I965_SURFACE_FLAG_TOP_FIELD_FIRST) {
3081 if (dn_filter_param) {
3082 float value = dn_filter_param->value;
3090 dn_strength = (int)(value * 31.0F);
3094 obj_surface = SURFACE(src_surface->id);
3095 orig_w = obj_surface->orig_width;
3096 orig_h = obj_surface->orig_height;
3097 w = obj_surface->width;
3098 h = obj_surface->height;
3100 if (pp_context->stmm.bo == NULL) {
3101 pp_context->stmm.bo = dri_bo_alloc(i965->intel.bufmgr,
3105 assert(pp_context->stmm.bo);
3108 /* source UV surface index 1 */
3109 gen7_pp_set_surface_state(ctx, pp_context,
3110 obj_surface->bo, w * h,
3111 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
3114 /* source YUV surface index 3 */
3115 gen7_pp_set_surface2_state(ctx, pp_context,
3119 SURFACE_FORMAT_PLANAR_420_8, 1,
3122 /* source STMM surface index 5 */
3123 gen7_pp_set_surface_state(ctx, pp_context,
3124 pp_context->stmm.bo, 0,
3125 orig_w, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
3128 /* destination surface */
3129 obj_surface = SURFACE(dst_surface->id);
3130 orig_w = obj_surface->orig_width;
3131 orig_h = obj_surface->orig_height;
3132 w = obj_surface->width;
3133 h = obj_surface->height;
3135 /* destination Y surface index 7 */
3136 gen7_pp_set_surface_state(ctx, pp_context,
3138 orig_w / 4, orig_h, w, I965_SURFACEFORMAT_R8_UNORM,
3141 /* destination UV surface index 8 */
3142 gen7_pp_set_surface_state(ctx, pp_context,
3143 obj_surface->bo, w * h,
3144 orig_w / 4, orig_h / 2, w, I965_SURFACEFORMAT_R8G8_UNORM,
3147 dri_bo_map(pp_context->sampler_state_table.bo, True);
3148 assert(pp_context->sampler_state_table.bo->virtual);
3149 assert(sizeof(*sampler_dn) == sizeof(int) * 8);
3150 sampler_dn = pp_context->sampler_state_table.bo->virtual;
3152 /* sample dn index 1 */
3154 sampler_dn[index].dw0.denoise_asd_threshold = 0;
3155 sampler_dn[index].dw0.dnmh_delt = 8;
3156 sampler_dn[index].dw0.vdi_walker_y_stride = 0;
3157 sampler_dn[index].dw0.vdi_walker_frame_sharing_enable = 0;
3158 sampler_dn[index].dw0.denoise_maximum_history = 128; // 128-240
3159 sampler_dn[index].dw0.denoise_stad_threshold = 0;
3161 sampler_dn[index].dw1.denoise_threshold_for_sum_of_complexity_measure = 64;
3162 sampler_dn[index].dw1.denoise_moving_pixel_threshold = 0;
3163 sampler_dn[index].dw1.stmm_c2 = 0;
3164 sampler_dn[index].dw1.low_temporal_difference_threshold = 8;
3165 sampler_dn[index].dw1.temporal_difference_threshold = 16;
3167 sampler_dn[index].dw2.block_noise_estimate_noise_threshold = dn_strength; // 0-31
3168 sampler_dn[index].dw2.bne_edge_th = 1;
3169 sampler_dn[index].dw2.smooth_mv_th = 0;
3170 sampler_dn[index].dw2.sad_tight_th = 5;
3171 sampler_dn[index].dw2.cat_slope_minus1 = 9;
3172 sampler_dn[index].dw2.good_neighbor_th = 4;
3174 sampler_dn[index].dw3.maximum_stmm = 128;
3175 sampler_dn[index].dw3.multipler_for_vecm = 2;
3176 sampler_dn[index].dw3.blending_constant_across_time_for_small_values_of_stmm = 0;
3177 sampler_dn[index].dw3.blending_constant_across_time_for_large_values_of_stmm = 64;
3178 sampler_dn[index].dw3.stmm_blending_constant_select = 0;
3180 sampler_dn[index].dw4.sdi_delta = 8;
3181 sampler_dn[index].dw4.sdi_threshold = 128;
3182 sampler_dn[index].dw4.stmm_output_shift = 7; // stmm_max - stmm_min = 2 ^ stmm_output_shift
3183 sampler_dn[index].dw4.stmm_shift_up = 0;
3184 sampler_dn[index].dw4.stmm_shift_down = 0;
3185 sampler_dn[index].dw4.minimum_stmm = 0;
3187 sampler_dn[index].dw5.fmd_temporal_difference_threshold = 0;
3188 sampler_dn[index].dw5.sdi_fallback_mode_2_constant = 0;
3189 sampler_dn[index].dw5.sdi_fallback_mode_1_t2_constant = 0;
3190 sampler_dn[index].dw5.sdi_fallback_mode_1_t1_constant = 0;
3192 sampler_dn[index].dw6.dn_enable = 1;
3193 sampler_dn[index].dw6.di_enable = 0;
3194 sampler_dn[index].dw6.di_partial = 0;
3195 sampler_dn[index].dw6.dndi_top_first = dndi_top_first;
3196 sampler_dn[index].dw6.dndi_stream_id = 1;
3197 sampler_dn[index].dw6.dndi_first_frame = 1;
3198 sampler_dn[index].dw6.progressive_dn = dn_progressive;
3199 sampler_dn[index].dw6.mcdi_enable = 0;
3200 sampler_dn[index].dw6.fmd_tear_threshold = 32;
3201 sampler_dn[index].dw6.cat_th1 = 0;
3202 sampler_dn[index].dw6.fmd2_vertical_difference_threshold = 32;
3203 sampler_dn[index].dw6.fmd1_vertical_difference_threshold = 32;
3205 sampler_dn[index].dw7.sad_tha = 5;
3206 sampler_dn[index].dw7.sad_thb = 10;
3207 sampler_dn[index].dw7.fmd_for_1st_field_of_current_frame = 2;
3208 sampler_dn[index].dw7.mc_pixel_consistency_th = 25;
3209 sampler_dn[index].dw7.fmd_for_2nd_field_of_previous_frame = 1;
3210 sampler_dn[index].dw7.vdi_walker_enable = 0;
3211 sampler_dn[index].dw7.neighborpixel_th = 10;
3212 sampler_dn[index].dw7.column_width_minus1 = w / 16;
3214 dri_bo_unmap(pp_context->sampler_state_table.bo);
3216 /* private function & data */
3217 pp_context->pp_x_steps = gen7_pp_dn_x_steps;
3218 pp_context->pp_y_steps = gen7_pp_dn_y_steps;
3219 pp_context->pp_set_block_parameter = gen7_pp_dn_set_block_parameter;
3221 pp_static_parameter->grf1.di_statistics_surface_pitch_div2 = w / 2;
3222 pp_static_parameter->grf1.di_statistics_surface_height_div4 = h / 4;
3223 pp_static_parameter->grf1.di_top_field_first = 0;
3224 pp_static_parameter->grf1.pointer_to_inline_parameter = 7;
3226 pp_static_parameter->grf2.di_destination_packed_y_component_offset = 0;
3227 pp_static_parameter->grf2.di_destination_packed_u_component_offset = 1;
3228 pp_static_parameter->grf2.di_destination_packed_v_component_offset = 3;
3230 pp_static_parameter->grf4.di_hoffset_svf_from_dvf = 0;
3231 pp_static_parameter->grf4.di_voffset_svf_from_dvf = 0;
3233 pp_dn_context->dest_w = w;
3234 pp_dn_context->dest_h = h;
3236 dst_surface->flags = src_surface->flags;
3238 return VA_STATUS_SUCCESS;
3242 ironlake_pp_initialize(
3243 VADriverContextP ctx,
3244 struct i965_post_processing_context *pp_context,
3245 const struct i965_surface *src_surface,
3246 const VARectangle *src_rect,
3247 struct i965_surface *dst_surface,
3248 const VARectangle *dst_rect,
3254 struct i965_driver_data *i965 = i965_driver_data(ctx);
3255 struct pp_module *pp_module;
3257 int static_param_size, inline_param_size;
3259 dri_bo_unreference(pp_context->surface_state_binding_table.bo);
3260 bo = dri_bo_alloc(i965->intel.bufmgr,
3261 "surface state & binding table",
3262 (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_PP_SURFACES,
3265 pp_context->surface_state_binding_table.bo = bo;
3267 dri_bo_unreference(pp_context->curbe.bo);
3268 bo = dri_bo_alloc(i965->intel.bufmgr,
3273 pp_context->curbe.bo = bo;
3275 dri_bo_unreference(pp_context->idrt.bo);
3276 bo = dri_bo_alloc(i965->intel.bufmgr,
3277 "interface discriptor",
3278 sizeof(struct i965_interface_descriptor),
3281 pp_context->idrt.bo = bo;
3282 pp_context->idrt.num_interface_descriptors = 0;
3284 dri_bo_unreference(pp_context->sampler_state_table.bo);
3285 bo = dri_bo_alloc(i965->intel.bufmgr,
3286 "sampler state table",
3290 dri_bo_map(bo, True);
3291 memset(bo->virtual, 0, bo->size);
3293 pp_context->sampler_state_table.bo = bo;
3295 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8);
3296 bo = dri_bo_alloc(i965->intel.bufmgr,
3297 "sampler 8x8 state ",
3301 pp_context->sampler_state_table.bo_8x8 = bo;
3303 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8_uv);
3304 bo = dri_bo_alloc(i965->intel.bufmgr,
3305 "sampler 8x8 state ",
3309 pp_context->sampler_state_table.bo_8x8_uv = bo;
3311 dri_bo_unreference(pp_context->vfe_state.bo);
3312 bo = dri_bo_alloc(i965->intel.bufmgr,
3314 sizeof(struct i965_vfe_state),
3317 pp_context->vfe_state.bo = bo;
3319 static_param_size = sizeof(struct pp_static_parameter);
3320 inline_param_size = sizeof(struct pp_inline_parameter);
3322 memset(pp_context->pp_static_parameter, 0, static_param_size);
3323 memset(pp_context->pp_inline_parameter, 0, inline_param_size);
3325 assert(pp_index >= PP_NULL && pp_index < NUM_PP_MODULES);
3326 pp_context->current_pp = pp_index;
3327 pp_module = &pp_context->pp_modules[pp_index];
3329 if (pp_module->initialize)
3330 va_status = pp_module->initialize(ctx, pp_context,
3337 va_status = VA_STATUS_ERROR_UNIMPLEMENTED;
3343 ironlake_post_processing(
3344 VADriverContextP ctx,
3345 struct i965_post_processing_context *pp_context,
3346 const struct i965_surface *src_surface,
3347 const VARectangle *src_rect,
3348 struct i965_surface *dst_surface,
3349 const VARectangle *dst_rect,
3356 va_status = ironlake_pp_initialize(ctx, pp_context,
3364 if (va_status == VA_STATUS_SUCCESS) {
3365 ironlake_pp_states_setup(ctx, pp_context);
3366 ironlake_pp_pipeline_setup(ctx, pp_context);
3374 VADriverContextP ctx,
3375 struct i965_post_processing_context *pp_context,
3376 const struct i965_surface *src_surface,
3377 const VARectangle *src_rect,
3378 struct i965_surface *dst_surface,
3379 const VARectangle *dst_rect,
3385 struct i965_driver_data *i965 = i965_driver_data(ctx);
3386 struct pp_module *pp_module;
3388 int static_param_size, inline_param_size;
3390 dri_bo_unreference(pp_context->surface_state_binding_table.bo);
3391 bo = dri_bo_alloc(i965->intel.bufmgr,
3392 "surface state & binding table",
3393 (SURFACE_STATE_PADDED_SIZE + sizeof(unsigned int)) * MAX_PP_SURFACES,
3396 pp_context->surface_state_binding_table.bo = bo;
3398 dri_bo_unreference(pp_context->curbe.bo);
3399 bo = dri_bo_alloc(i965->intel.bufmgr,
3404 pp_context->curbe.bo = bo;
3406 dri_bo_unreference(pp_context->idrt.bo);
3407 bo = dri_bo_alloc(i965->intel.bufmgr,
3408 "interface discriptor",
3409 sizeof(struct gen6_interface_descriptor_data),
3412 pp_context->idrt.bo = bo;
3413 pp_context->idrt.num_interface_descriptors = 0;
3415 dri_bo_unreference(pp_context->sampler_state_table.bo);
3416 bo = dri_bo_alloc(i965->intel.bufmgr,
3417 "sampler state table",
3421 dri_bo_map(bo, True);
3422 memset(bo->virtual, 0, bo->size);
3424 pp_context->sampler_state_table.bo = bo;
3426 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8);
3427 bo = dri_bo_alloc(i965->intel.bufmgr,
3428 "sampler 8x8 state ",
3432 pp_context->sampler_state_table.bo_8x8 = bo;
3434 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8_uv);
3435 bo = dri_bo_alloc(i965->intel.bufmgr,
3436 "sampler 8x8 state ",
3440 pp_context->sampler_state_table.bo_8x8_uv = bo;
3442 dri_bo_unreference(pp_context->vfe_state.bo);
3443 bo = dri_bo_alloc(i965->intel.bufmgr,
3445 sizeof(struct i965_vfe_state),
3448 pp_context->vfe_state.bo = bo;
3450 if (IS_GEN7(i965->intel.device_id)) {
3451 static_param_size = sizeof(struct gen7_pp_static_parameter);
3452 inline_param_size = sizeof(struct gen7_pp_inline_parameter);
3454 static_param_size = sizeof(struct pp_static_parameter);
3455 inline_param_size = sizeof(struct pp_inline_parameter);
3458 memset(pp_context->pp_static_parameter, 0, static_param_size);
3459 memset(pp_context->pp_inline_parameter, 0, inline_param_size);
3461 assert(pp_index >= PP_NULL && pp_index < NUM_PP_MODULES);
3462 pp_context->current_pp = pp_index;
3463 pp_module = &pp_context->pp_modules[pp_index];
3465 if (pp_module->initialize)
3466 va_status = pp_module->initialize(ctx, pp_context,
3473 va_status = VA_STATUS_ERROR_UNIMPLEMENTED;
3479 gen6_pp_interface_descriptor_table(VADriverContextP ctx,
3480 struct i965_post_processing_context *pp_context)
3482 struct i965_driver_data *i965 = i965_driver_data(ctx);
3483 struct gen6_interface_descriptor_data *desc;
3485 int pp_index = pp_context->current_pp;
3487 bo = pp_context->idrt.bo;
3488 dri_bo_map(bo, True);
3489 assert(bo->virtual);
3491 memset(desc, 0, sizeof(*desc));
3492 desc->desc0.kernel_start_pointer =
3493 pp_context->pp_modules[pp_index].kernel.bo->offset >> 6; /* reloc */
3494 desc->desc1.single_program_flow = 1;
3495 desc->desc1.floating_point_mode = FLOATING_POINT_IEEE_754;
3496 desc->desc2.sampler_count = 1; /* 1 - 4 samplers used */
3497 desc->desc2.sampler_state_pointer =
3498 pp_context->sampler_state_table.bo->offset >> 5;
3499 desc->desc3.binding_table_entry_count = 0;
3500 desc->desc3.binding_table_pointer = (BINDING_TABLE_OFFSET >> 5);
3501 desc->desc4.constant_urb_entry_read_offset = 0;
3503 if (IS_GEN7(i965->intel.device_id))
3504 desc->desc4.constant_urb_entry_read_length = 6; /* grf 1-6 */
3506 desc->desc4.constant_urb_entry_read_length = 4; /* grf 1-4 */
3508 dri_bo_emit_reloc(bo,
3509 I915_GEM_DOMAIN_INSTRUCTION, 0,
3511 offsetof(struct gen6_interface_descriptor_data, desc0),
3512 pp_context->pp_modules[pp_index].kernel.bo);
3514 dri_bo_emit_reloc(bo,
3515 I915_GEM_DOMAIN_INSTRUCTION, 0,
3516 desc->desc2.sampler_count << 2,
3517 offsetof(struct gen6_interface_descriptor_data, desc2),
3518 pp_context->sampler_state_table.bo);
3521 pp_context->idrt.num_interface_descriptors++;
3525 gen6_pp_upload_constants(VADriverContextP ctx,
3526 struct i965_post_processing_context *pp_context)
3528 struct i965_driver_data *i965 = i965_driver_data(ctx);
3529 unsigned char *constant_buffer;
3532 assert(sizeof(struct pp_static_parameter) == 128);
3533 assert(sizeof(struct gen7_pp_static_parameter) == 192);
3535 if (IS_GEN7(i965->intel.device_id))
3536 param_size = sizeof(struct gen7_pp_static_parameter);
3538 param_size = sizeof(struct pp_static_parameter);
3540 dri_bo_map(pp_context->curbe.bo, 1);
3541 assert(pp_context->curbe.bo->virtual);
3542 constant_buffer = pp_context->curbe.bo->virtual;
3543 memcpy(constant_buffer, pp_context->pp_static_parameter, param_size);
3544 dri_bo_unmap(pp_context->curbe.bo);
3548 gen6_pp_states_setup(VADriverContextP ctx,
3549 struct i965_post_processing_context *pp_context)
3551 gen6_pp_interface_descriptor_table(ctx, pp_context);
3552 gen6_pp_upload_constants(ctx, pp_context);
3556 gen6_pp_pipeline_select(VADriverContextP ctx,
3557 struct i965_post_processing_context *pp_context)
3559 struct intel_batchbuffer *batch = pp_context->batch;
3561 BEGIN_BATCH(batch, 1);
3562 OUT_BATCH(batch, CMD_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA);
3563 ADVANCE_BATCH(batch);
3567 gen6_pp_state_base_address(VADriverContextP ctx,
3568 struct i965_post_processing_context *pp_context)
3570 struct intel_batchbuffer *batch = pp_context->batch;
3572 BEGIN_BATCH(batch, 10);
3573 OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | (10 - 2));
3574 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3575 OUT_RELOC(batch, pp_context->surface_state_binding_table.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY); /* Surface state base address */
3576 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3577 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3578 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3579 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3580 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3581 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3582 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
3583 ADVANCE_BATCH(batch);
3587 gen6_pp_vfe_state(VADriverContextP ctx,
3588 struct i965_post_processing_context *pp_context)
3590 struct intel_batchbuffer *batch = pp_context->batch;
3592 BEGIN_BATCH(batch, 8);
3593 OUT_BATCH(batch, CMD_MEDIA_VFE_STATE | (8 - 2));
3594 OUT_BATCH(batch, 0);
3596 (pp_context->urb.num_vfe_entries - 1) << 16 |
3597 pp_context->urb.num_vfe_entries << 8);
3598 OUT_BATCH(batch, 0);
3600 (pp_context->urb.size_vfe_entry * 2) << 16 | /* URB Entry Allocation Size, in 256 bits unit */
3601 (pp_context->urb.size_cs_entry * pp_context->urb.num_cs_entries * 2)); /* CURBE Allocation Size, in 256 bits unit */
3602 OUT_BATCH(batch, 0);
3603 OUT_BATCH(batch, 0);
3604 OUT_BATCH(batch, 0);
3605 ADVANCE_BATCH(batch);
3609 gen6_pp_curbe_load(VADriverContextP ctx,
3610 struct i965_post_processing_context *pp_context)
3612 struct intel_batchbuffer *batch = pp_context->batch;
3614 assert(pp_context->urb.size_cs_entry * pp_context->urb.num_cs_entries * 2 * 32 <= pp_context->curbe.bo->size);
3616 BEGIN_BATCH(batch, 4);
3617 OUT_BATCH(batch, CMD_MEDIA_CURBE_LOAD | (4 - 2));
3618 OUT_BATCH(batch, 0);
3620 pp_context->urb.size_cs_entry * pp_context->urb.num_cs_entries * 2 * 32);
3622 pp_context->curbe.bo,
3623 I915_GEM_DOMAIN_INSTRUCTION, 0,
3625 ADVANCE_BATCH(batch);
3629 gen6_interface_descriptor_load(VADriverContextP ctx,
3630 struct i965_post_processing_context *pp_context)
3632 struct intel_batchbuffer *batch = pp_context->batch;
3634 BEGIN_BATCH(batch, 4);
3635 OUT_BATCH(batch, CMD_MEDIA_INTERFACE_DESCRIPTOR_LOAD | (4 - 2));
3636 OUT_BATCH(batch, 0);
3638 pp_context->idrt.num_interface_descriptors * sizeof(struct gen6_interface_descriptor_data));
3640 pp_context->idrt.bo,
3641 I915_GEM_DOMAIN_INSTRUCTION, 0,
3643 ADVANCE_BATCH(batch);
3647 gen6_pp_object_walker(VADriverContextP ctx,
3648 struct i965_post_processing_context *pp_context)
3650 struct i965_driver_data *i965 = i965_driver_data(ctx);
3651 struct intel_batchbuffer *batch = pp_context->batch;
3652 int x, x_steps, y, y_steps;
3653 int param_size, command_length_in_dws;
3654 dri_bo *command_buffer;
3655 unsigned int *command_ptr;
3657 if (IS_GEN7(i965->intel.device_id))
3658 param_size = sizeof(struct gen7_pp_inline_parameter);
3660 param_size = sizeof(struct pp_inline_parameter);
3662 x_steps = pp_context->pp_x_steps(&pp_context->private_context);
3663 y_steps = pp_context->pp_y_steps(&pp_context->private_context);
3664 command_length_in_dws = 6 + (param_size >> 2);
3665 command_buffer = dri_bo_alloc(i965->intel.bufmgr,
3666 "command objects buffer",
3667 command_length_in_dws * 4 * x_steps * y_steps + 8,
3670 dri_bo_map(command_buffer, 1);
3671 command_ptr = command_buffer->virtual;
3673 for (y = 0; y < y_steps; y++) {
3674 for (x = 0; x < x_steps; x++) {
3675 if (!pp_context->pp_set_block_parameter(pp_context, x, y)) {
3676 *command_ptr++ = (CMD_MEDIA_OBJECT | (command_length_in_dws - 2));
3682 memcpy(command_ptr, pp_context->pp_inline_parameter, param_size);
3683 command_ptr += (param_size >> 2);
3688 if (command_length_in_dws * x_steps * y_steps % 2 == 0)
3691 *command_ptr = MI_BATCH_BUFFER_END;
3693 dri_bo_unmap(command_buffer);
3695 BEGIN_BATCH(batch, 2);
3696 OUT_BATCH(batch, MI_BATCH_BUFFER_START | (2 << 6));
3697 OUT_RELOC(batch, command_buffer,
3698 I915_GEM_DOMAIN_COMMAND, 0,
3700 ADVANCE_BATCH(batch);
3702 dri_bo_unreference(command_buffer);
3704 /* Have to execute the batch buffer here becuase MI_BATCH_BUFFER_END
3705 * will cause control to pass back to ring buffer
3707 intel_batchbuffer_end_atomic(batch);
3708 intel_batchbuffer_flush(batch);
3709 intel_batchbuffer_start_atomic(batch, 0x1000);
3713 gen6_pp_pipeline_setup(VADriverContextP ctx,
3714 struct i965_post_processing_context *pp_context)
3716 struct intel_batchbuffer *batch = pp_context->batch;
3718 intel_batchbuffer_start_atomic(batch, 0x1000);
3719 intel_batchbuffer_emit_mi_flush(batch);
3720 gen6_pp_pipeline_select(ctx, pp_context);
3721 gen6_pp_state_base_address(ctx, pp_context);
3722 gen6_pp_vfe_state(ctx, pp_context);
3723 gen6_pp_curbe_load(ctx, pp_context);
3724 gen6_interface_descriptor_load(ctx, pp_context);
3725 gen6_pp_object_walker(ctx, pp_context);
3726 intel_batchbuffer_end_atomic(batch);
3730 gen6_post_processing(
3731 VADriverContextP ctx,
3732 struct i965_post_processing_context *pp_context,
3733 const struct i965_surface *src_surface,
3734 const VARectangle *src_rect,
3735 struct i965_surface *dst_surface,
3736 const VARectangle *dst_rect,
3743 va_status = gen6_pp_initialize(ctx, pp_context,
3751 if (va_status == VA_STATUS_SUCCESS) {
3752 gen6_pp_states_setup(ctx, pp_context);
3753 gen6_pp_pipeline_setup(ctx, pp_context);
3760 i965_post_processing_internal(
3761 VADriverContextP ctx,
3762 struct i965_post_processing_context *pp_context,
3763 const struct i965_surface *src_surface,
3764 const VARectangle *src_rect,
3765 struct i965_surface *dst_surface,
3766 const VARectangle *dst_rect,
3771 struct i965_driver_data *i965 = i965_driver_data(ctx);
3774 if (IS_GEN6(i965->intel.device_id) ||
3775 IS_GEN7(i965->intel.device_id))
3776 va_status = gen6_post_processing(ctx, pp_context, src_surface, src_rect, dst_surface, dst_rect, pp_index, filter_param);
3778 va_status = ironlake_post_processing(ctx, pp_context, src_surface, src_rect, dst_surface, dst_rect, pp_index, filter_param);
3784 i965_DestroySurfaces(VADriverContextP ctx,
3785 VASurfaceID *surface_list,
3788 i965_CreateSurfaces(VADriverContextP ctx,
3793 VASurfaceID *surfaces);
3796 rgb_to_yuv(unsigned int argb,
3802 int r = ((argb >> 16) & 0xff);
3803 int g = ((argb >> 8) & 0xff);
3804 int b = ((argb >> 0) & 0xff);
3806 *y = (257 * r + 504 * g + 98 * b) / 1000 + 16;
3807 *v = (439 * r - 368 * g - 71 * b) / 1000 + 128;
3808 *u = (-148 * r - 291 * g + 439 * b) / 1000 + 128;
3809 *a = ((argb >> 24) & 0xff);
3813 i965_vpp_clear_surface(VADriverContextP ctx,
3814 struct i965_post_processing_context *pp_context,
3815 VASurfaceID surface,
3818 struct i965_driver_data *i965 = i965_driver_data(ctx);
3819 struct intel_batchbuffer *batch = pp_context->batch;
3820 struct object_surface *obj_surface = SURFACE(surface);
3821 unsigned int blt_cmd, br13;
3822 unsigned int tiling = 0, swizzle = 0;
3824 unsigned char y, u, v, a = 0;
3826 /* Currently only support NV12 surface */
3827 if (!obj_surface || obj_surface->fourcc != VA_FOURCC('N', 'V', '1', '2'))
3830 rgb_to_yuv(color, &y, &u, &v, &a);
3835 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
3836 blt_cmd = XY_COLOR_BLT_CMD;
3837 pitch = obj_surface->width;
3839 if (tiling != I915_TILING_NONE) {
3840 blt_cmd |= XY_COLOR_BLT_DST_TILED;
3848 if (IS_GEN6(i965->intel.device_id) ||
3849 IS_GEN7(i965->intel.device_id)) {
3850 intel_batchbuffer_start_atomic_blt(batch, 48);
3851 BEGIN_BLT_BATCH(batch, 12);
3853 intel_batchbuffer_start_atomic(batch, 48);
3854 BEGIN_BATCH(batch, 12);
3857 OUT_BATCH(batch, blt_cmd);
3858 OUT_BATCH(batch, br13);
3863 obj_surface->height << 16 |
3864 obj_surface->width);
3865 OUT_RELOC(batch, obj_surface->bo,
3866 I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
3868 OUT_BATCH(batch, y);
3874 OUT_BATCH(batch, blt_cmd);
3875 OUT_BATCH(batch, br13);
3880 obj_surface->height / 2 << 16 |
3881 obj_surface->width / 2);
3882 OUT_RELOC(batch, obj_surface->bo,
3883 I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
3884 obj_surface->width * obj_surface->y_cb_offset);
3885 OUT_BATCH(batch, v << 8 | u);
3887 ADVANCE_BATCH(batch);
3888 intel_batchbuffer_end_atomic(batch);
3892 i965_post_processing(
3893 VADriverContextP ctx,
3894 VASurfaceID surface,
3895 const VARectangle *src_rect,
3896 const VARectangle *dst_rect,
3898 int *has_done_scaling
3901 struct i965_driver_data *i965 = i965_driver_data(ctx);
3902 VASurfaceID in_surface_id = surface;
3903 VASurfaceID out_surface_id = VA_INVALID_ID;
3905 *has_done_scaling = 0;
3908 struct object_surface *obj_surface;
3910 struct i965_surface src_surface;
3911 struct i965_surface dst_surface;
3913 obj_surface = SURFACE(in_surface_id);
3915 /* Currently only support post processing for NV12 surface */
3916 if (obj_surface->fourcc != VA_FOURCC('N', 'V', '1', '2'))
3917 return out_surface_id;
3919 _i965LockMutex(&i965->pp_mutex);
3921 if (flags & I965_PP_FLAG_MCDI) {
3922 status = i965_CreateSurfaces(ctx,
3923 obj_surface->orig_width,
3924 obj_surface->orig_height,
3925 VA_RT_FORMAT_YUV420,
3928 assert(status == VA_STATUS_SUCCESS);
3929 obj_surface = SURFACE(out_surface_id);
3930 i965_check_alloc_surface_bo(ctx, obj_surface, 0, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
3931 i965_vpp_clear_surface(ctx, i965->pp_context, out_surface_id, 0);
3932 src_surface.id = in_surface_id;
3933 src_surface.type = I965_SURFACE_TYPE_SURFACE;
3934 src_surface.flags = (flags & I965_PP_FLAG_TOP_FIELD) ?
3935 I965_SURFACE_FLAG_TOP_FIELD_FIRST : I965_SURFACE_FLAG_BOTTOME_FIELD_FIRST;
3936 dst_surface.id = out_surface_id;
3937 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
3938 dst_surface.flags = I965_SURFACE_FLAG_FRAME;
3940 i965_post_processing_internal(ctx, i965->pp_context,
3949 if (flags & I965_PP_FLAG_AVS) {
3950 struct i965_render_state *render_state = &i965->render_state;
3951 struct intel_region *dest_region = render_state->draw_region;
3953 if (out_surface_id != VA_INVALID_ID)
3954 in_surface_id = out_surface_id;
3956 status = i965_CreateSurfaces(ctx,
3958 dest_region->height,
3959 VA_RT_FORMAT_YUV420,
3962 assert(status == VA_STATUS_SUCCESS);
3963 obj_surface = SURFACE(out_surface_id);
3964 i965_check_alloc_surface_bo(ctx, obj_surface, 0, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
3965 i965_vpp_clear_surface(ctx, i965->pp_context, out_surface_id, 0);
3966 src_surface.id = in_surface_id;
3967 src_surface.type = I965_SURFACE_TYPE_SURFACE;
3968 src_surface.flags = I965_SURFACE_FLAG_FRAME;
3969 dst_surface.id = out_surface_id;
3970 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
3971 dst_surface.flags = I965_SURFACE_FLAG_FRAME;
3973 i965_post_processing_internal(ctx, i965->pp_context,
3981 if (in_surface_id != surface)
3982 i965_DestroySurfaces(ctx, &in_surface_id, 1);
3984 *has_done_scaling = 1;
3987 _i965UnlockMutex(&i965->pp_mutex);
3990 return out_surface_id;
3994 i965_image_pl3_processing(VADriverContextP ctx,
3995 const struct i965_surface *src_surface,
3996 const VARectangle *src_rect,
3997 struct i965_surface *dst_surface,
3998 const VARectangle *dst_rect)
4000 struct i965_driver_data *i965 = i965_driver_data(ctx);
4001 struct i965_post_processing_context *pp_context = i965->pp_context;
4002 int fourcc = pp_get_surface_fourcc(ctx, dst_surface);
4003 VAStatus vaStatus = VA_STATUS_ERROR_UNIMPLEMENTED;
4005 if (fourcc == VA_FOURCC('N', 'V', '1', '2')) {
4006 vaStatus = i965_post_processing_internal(ctx, i965->pp_context,
4011 PP_PL3_LOAD_SAVE_N12,
4013 } else if (fourcc == VA_FOURCC('I', 'M', 'C', '1') ||
4014 fourcc == VA_FOURCC('I', 'M', 'C', '3') ||
4015 fourcc == VA_FOURCC('Y', 'V', '1', '2') ||
4016 fourcc == VA_FOURCC('I', '4', '2', '0')) {
4017 vaStatus = i965_post_processing_internal(ctx, i965->pp_context,
4022 PP_PL3_LOAD_SAVE_PL3,
4024 } else if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
4025 vaStatus = i965_post_processing_internal(ctx, i965->pp_context,
4030 PP_PL3_LOAD_SAVE_PA,
4037 intel_batchbuffer_flush(pp_context->batch);
4043 i965_image_pl2_processing(VADriverContextP ctx,
4044 const struct i965_surface *src_surface,
4045 const VARectangle *src_rect,
4046 struct i965_surface *dst_surface,
4047 const VARectangle *dst_rect)
4049 struct i965_driver_data *i965 = i965_driver_data(ctx);
4050 struct i965_post_processing_context *pp_context = i965->pp_context;
4051 int fourcc = pp_get_surface_fourcc(ctx, dst_surface);
4052 VAStatus vaStatus = VA_STATUS_ERROR_UNIMPLEMENTED;
4054 if (fourcc == VA_FOURCC('N', 'V', '1', '2')) {
4055 vaStatus = i965_post_processing_internal(ctx, i965->pp_context,
4060 PP_NV12_LOAD_SAVE_N12,
4062 } else if (fourcc == VA_FOURCC('I', 'M', 'C', '1') ||
4063 fourcc == VA_FOURCC('I', 'M', 'C', '3') ||
4064 fourcc == VA_FOURCC('Y', 'V', '1', '2') ||
4065 fourcc == VA_FOURCC('I', '4', '2', '0') ) {
4066 vaStatus = i965_post_processing_internal(ctx, i965->pp_context,
4071 PP_NV12_LOAD_SAVE_PL3,
4073 } else if (fourcc == VA_FOURCC('Y', 'U', 'Y', '2')) {
4074 vaStatus = i965_post_processing_internal(ctx, i965->pp_context,
4079 PP_NV12_LOAD_SAVE_PA,
4083 intel_batchbuffer_flush(pp_context->batch);
4089 i965_image_pl1_processing(VADriverContextP ctx,
4090 const struct i965_surface *src_surface,
4091 const VARectangle *src_rect,
4092 struct i965_surface *dst_surface,
4093 const VARectangle *dst_rect)
4095 struct i965_driver_data *i965 = i965_driver_data(ctx);
4096 struct i965_post_processing_context *pp_context = i965->pp_context;
4097 int fourcc = pp_get_surface_fourcc(ctx, dst_surface);
4099 if (fourcc == VA_FOURCC('N', 'V', '1', '2')) {
4100 i965_post_processing_internal(ctx, i965->pp_context,
4105 PP_PA_LOAD_SAVE_NV12,
4108 else if (fourcc == VA_FOURCC_YV12) {
4109 i965_post_processing_internal(ctx, i965->pp_context,
4114 PP_PA_LOAD_SAVE_PL3,
4119 return VA_STATUS_ERROR_UNKNOWN;
4122 intel_batchbuffer_flush(pp_context->batch);
4124 return VA_STATUS_SUCCESS;
4128 i965_image_processing(VADriverContextP ctx,
4129 const struct i965_surface *src_surface,
4130 const VARectangle *src_rect,
4131 struct i965_surface *dst_surface,
4132 const VARectangle *dst_rect)
4134 struct i965_driver_data *i965 = i965_driver_data(ctx);
4135 VAStatus status = VA_STATUS_ERROR_UNIMPLEMENTED;
4138 int fourcc = pp_get_surface_fourcc(ctx, src_surface);
4140 _i965LockMutex(&i965->pp_mutex);
4143 case VA_FOURCC('Y', 'V', '1', '2'):
4144 case VA_FOURCC('I', '4', '2', '0'):
4145 case VA_FOURCC('I', 'M', 'C', '1'):
4146 case VA_FOURCC('I', 'M', 'C', '3'):
4147 status = i965_image_pl3_processing(ctx,
4154 case VA_FOURCC('N', 'V', '1', '2'):
4155 status = i965_image_pl2_processing(ctx,
4161 case VA_FOURCC('Y', 'U', 'Y', '2'):
4162 status = i965_image_pl1_processing(ctx,
4170 status = VA_STATUS_ERROR_UNIMPLEMENTED;
4174 _i965UnlockMutex(&i965->pp_mutex);
4181 i965_post_processing_context_finalize(struct i965_post_processing_context *pp_context)
4185 dri_bo_unreference(pp_context->surface_state_binding_table.bo);
4186 pp_context->surface_state_binding_table.bo = NULL;
4188 dri_bo_unreference(pp_context->curbe.bo);
4189 pp_context->curbe.bo = NULL;
4191 dri_bo_unreference(pp_context->sampler_state_table.bo);
4192 pp_context->sampler_state_table.bo = NULL;
4194 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8);
4195 pp_context->sampler_state_table.bo_8x8 = NULL;
4197 dri_bo_unreference(pp_context->sampler_state_table.bo_8x8_uv);
4198 pp_context->sampler_state_table.bo_8x8_uv = NULL;
4200 dri_bo_unreference(pp_context->idrt.bo);
4201 pp_context->idrt.bo = NULL;
4202 pp_context->idrt.num_interface_descriptors = 0;
4204 dri_bo_unreference(pp_context->vfe_state.bo);
4205 pp_context->vfe_state.bo = NULL;
4207 dri_bo_unreference(pp_context->stmm.bo);
4208 pp_context->stmm.bo = NULL;
4210 for (i = 0; i < NUM_PP_MODULES; i++) {
4211 struct pp_module *pp_module = &pp_context->pp_modules[i];
4213 dri_bo_unreference(pp_module->kernel.bo);
4214 pp_module->kernel.bo = NULL;
4217 free(pp_context->pp_static_parameter);
4218 free(pp_context->pp_inline_parameter);
4219 pp_context->pp_static_parameter = NULL;
4220 pp_context->pp_inline_parameter = NULL;
4224 i965_post_processing_terminate(VADriverContextP ctx)
4226 struct i965_driver_data *i965 = i965_driver_data(ctx);
4227 struct i965_post_processing_context *pp_context = i965->pp_context;
4230 i965_post_processing_context_finalize(pp_context);
4234 i965->pp_context = NULL;
4240 i965_post_processing_context_init(VADriverContextP ctx,
4241 struct i965_post_processing_context *pp_context,
4242 struct intel_batchbuffer *batch)
4244 struct i965_driver_data *i965 = i965_driver_data(ctx);
4247 pp_context->urb.size = URB_SIZE((&i965->intel));
4248 pp_context->urb.num_vfe_entries = 32;
4249 pp_context->urb.size_vfe_entry = 1; /* in 512 bits unit */
4250 pp_context->urb.num_cs_entries = 1;
4252 if (IS_GEN7(i965->intel.device_id))
4253 pp_context->urb.size_cs_entry = 4; /* in 512 bits unit */
4255 pp_context->urb.size_cs_entry = 2;
4257 pp_context->urb.vfe_start = 0;
4258 pp_context->urb.cs_start = pp_context->urb.vfe_start +
4259 pp_context->urb.num_vfe_entries * pp_context->urb.size_vfe_entry;
4260 assert(pp_context->urb.cs_start +
4261 pp_context->urb.num_cs_entries * pp_context->urb.size_cs_entry <= URB_SIZE((&i965->intel)));
4263 assert(NUM_PP_MODULES == ARRAY_ELEMS(pp_modules_gen5));
4264 assert(NUM_PP_MODULES == ARRAY_ELEMS(pp_modules_gen6));
4265 assert(NUM_PP_MODULES == ARRAY_ELEMS(pp_modules_gen7));
4267 if (IS_GEN7(i965->intel.device_id))
4268 memcpy(pp_context->pp_modules, pp_modules_gen7, sizeof(pp_context->pp_modules));
4269 else if (IS_GEN6(i965->intel.device_id))
4270 memcpy(pp_context->pp_modules, pp_modules_gen6, sizeof(pp_context->pp_modules));
4271 else if (IS_IRONLAKE(i965->intel.device_id))
4272 memcpy(pp_context->pp_modules, pp_modules_gen5, sizeof(pp_context->pp_modules));
4274 for (i = 0; i < NUM_PP_MODULES; i++) {
4275 struct pp_module *pp_module = &pp_context->pp_modules[i];
4276 dri_bo_unreference(pp_module->kernel.bo);
4277 if (pp_module->kernel.bin && pp_module->kernel.size) {
4278 pp_module->kernel.bo = dri_bo_alloc(i965->intel.bufmgr,
4279 pp_module->kernel.name,
4280 pp_module->kernel.size,
4282 assert(pp_module->kernel.bo);
4283 dri_bo_subdata(pp_module->kernel.bo, 0, pp_module->kernel.size, pp_module->kernel.bin);
4285 pp_module->kernel.bo = NULL;
4289 /* static & inline parameters */
4290 if (IS_GEN7(i965->intel.device_id)) {
4291 pp_context->pp_static_parameter = calloc(sizeof(struct gen7_pp_static_parameter), 1);
4292 pp_context->pp_inline_parameter = calloc(sizeof(struct gen7_pp_inline_parameter), 1);
4294 pp_context->pp_static_parameter = calloc(sizeof(struct pp_static_parameter), 1);
4295 pp_context->pp_inline_parameter = calloc(sizeof(struct pp_inline_parameter), 1);
4298 pp_context->batch = batch;
4302 i965_post_processing_init(VADriverContextP ctx)
4304 struct i965_driver_data *i965 = i965_driver_data(ctx);
4305 struct i965_post_processing_context *pp_context = i965->pp_context;
4308 if (pp_context == NULL) {
4309 pp_context = calloc(1, sizeof(*pp_context));
4310 i965_post_processing_context_init(ctx, pp_context, i965->batch);
4311 i965->pp_context = pp_context;
4318 static const int procfilter_to_pp_flag[VAProcFilterCount] = {
4319 PP_NULL, /* VAProcFilterNone */
4320 PP_NV12_DN, /* VAProcFilterNoiseReduction */
4321 PP_NULL, /* VAProcFilterDeblocking */
4322 PP_NV12_DNDI, /* VAProcFilterDeinterlacing */
4323 PP_NULL, /* VAProcFilterSharpening */
4324 PP_NULL, /* VAProcFilterColorBalance */
4325 PP_NULL, /* VAProcFilterColorStandard */
4326 PP_NULL, /* VAProcFilterFrameRateConversion */
4329 static const int proc_frame_to_pp_frame[3] = {
4330 I965_SURFACE_FLAG_FRAME,
4331 I965_SURFACE_FLAG_TOP_FIELD_FIRST,
4332 I965_SURFACE_FLAG_BOTTOME_FIELD_FIRST
4336 i965_proc_picture(VADriverContextP ctx,
4338 union codec_state *codec_state,
4339 struct hw_context *hw_context)
4341 struct i965_driver_data *i965 = i965_driver_data(ctx);
4342 struct i965_proc_context *proc_context = (struct i965_proc_context *)hw_context;
4343 struct proc_state *proc_state = &codec_state->proc;
4344 VAProcPipelineParameterBuffer *pipeline_param = (VAProcPipelineParameterBuffer *)proc_state->pipeline_param->buffer;
4345 struct object_surface *obj_surface;
4346 struct i965_surface src_surface, dst_surface;
4347 VARectangle src_rect, dst_rect;
4350 VASurfaceID tmp_surfaces[VAProcFilterCount + 4];
4351 int num_tmp_surfaces = 0;
4352 unsigned int tiling = 0, swizzle = 0;
4353 int in_width, in_height;
4355 assert(pipeline_param->surface != VA_INVALID_ID);
4356 assert(proc_state->current_render_target != VA_INVALID_ID);
4358 obj_surface = SURFACE(pipeline_param->surface);
4359 in_width = obj_surface->orig_width;
4360 in_height = obj_surface->orig_height;
4361 dri_bo_get_tiling(obj_surface->bo, &tiling, &swizzle);
4363 src_surface.id = pipeline_param->surface;
4364 src_surface.type = I965_SURFACE_TYPE_SURFACE;
4365 src_surface.flags = proc_frame_to_pp_frame[pipeline_param->filter_flags & 0x3];
4367 if (obj_surface->fourcc != VA_FOURCC('N', 'V', '1', '2')) {
4368 VASurfaceID out_surface_id = VA_INVALID_ID;
4370 src_surface.id = pipeline_param->surface;
4371 src_surface.type = I965_SURFACE_TYPE_SURFACE;
4372 src_surface.flags = I965_SURFACE_FLAG_FRAME;
4375 src_rect.width = in_width;
4376 src_rect.height = in_height;
4378 status = i965_CreateSurfaces(ctx,
4381 VA_RT_FORMAT_YUV420,
4384 assert(status == VA_STATUS_SUCCESS);
4385 tmp_surfaces[num_tmp_surfaces++] = out_surface_id;
4386 obj_surface = SURFACE(out_surface_id);
4387 i965_check_alloc_surface_bo(ctx, obj_surface, !!tiling, VA_FOURCC('N', 'V', '1', '2'), SUBSAMPLE_YUV420);
4389 dst_surface.id = out_surface_id;
4390 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
4391 dst_surface.flags = I965_SURFACE_FLAG_FRAME;
4394 dst_rect.width = in_width;
4395 dst_rect.height = in_height;
4397 status = i965_image_processing(ctx,
4402 assert(status == VA_STATUS_SUCCESS);
4404 src_surface.id = out_surface_id;
4405 src_surface.type = I965_SURFACE_TYPE_SURFACE;
4406 src_surface.flags = proc_frame_to_pp_frame[pipeline_param->filter_flags & 0x3];
4409 if (pipeline_param->surface_region) {
4410 src_rect.x = pipeline_param->surface_region->x;
4411 src_rect.y = pipeline_param->surface_region->y;
4412 src_rect.width = pipeline_param->surface_region->width;
4413 src_rect.height = pipeline_param->surface_region->height;
4417 src_rect.width = in_width;
4418 src_rect.height = in_height;
4421 if (pipeline_param->output_region) {
4422 dst_rect.x = pipeline_param->output_region->x;
4423 dst_rect.y = pipeline_param->output_region->y;
4424 dst_rect.width = pipeline_param->output_region->width;
4425 dst_rect.height = pipeline_param->output_region->height;
4429 dst_rect.width = in_width;
4430 dst_rect.height = in_height;
4433 obj_surface = SURFACE(proc_state->current_render_target);
4434 i965_check_alloc_surface_bo(ctx, obj_surface, !!tiling, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
4435 i965_vpp_clear_surface(ctx, &proc_context->pp_context, proc_state->current_render_target, pipeline_param->output_background_color);
4437 for (i = 0; i < pipeline_param->num_filters; i++) {
4438 struct object_buffer *obj_buffer = BUFFER(pipeline_param->filters[i]);
4439 VAProcFilterParameterBufferBase *filter_param = (VAProcFilterParameterBufferBase *)obj_buffer->buffer_store->buffer;
4440 VAProcFilterType filter_type = filter_param->type;
4441 VASurfaceID out_surface_id = VA_INVALID_ID;
4442 int kernel_index = procfilter_to_pp_flag[filter_type];
4444 if (kernel_index != PP_NULL &&
4445 proc_context->pp_context.pp_modules[kernel_index].kernel.bo != NULL) {
4446 status = i965_CreateSurfaces(ctx,
4449 VA_RT_FORMAT_YUV420,
4452 assert(status == VA_STATUS_SUCCESS);
4453 tmp_surfaces[num_tmp_surfaces++] = out_surface_id;
4454 obj_surface = SURFACE(out_surface_id);
4455 i965_check_alloc_surface_bo(ctx, obj_surface, !!tiling, VA_FOURCC('N','V','1','2'), SUBSAMPLE_YUV420);
4456 dst_surface.id = out_surface_id;
4457 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
4458 status = i965_post_processing_internal(ctx, &proc_context->pp_context,
4466 if (status == VA_STATUS_SUCCESS) {
4467 src_surface.id = dst_surface.id;
4468 src_surface.type = dst_surface.type;
4469 src_surface.flags = dst_surface.flags;
4474 dst_surface.id = proc_state->current_render_target;
4475 dst_surface.type = I965_SURFACE_TYPE_SURFACE;
4477 if (src_rect.width == dst_rect.width &&
4478 src_rect.height == dst_rect.height) {
4479 i965_post_processing_internal(ctx, &proc_context->pp_context,
4484 PP_NV12_LOAD_SAVE_N12,
4488 i965_post_processing_internal(ctx, &proc_context->pp_context,
4493 (pipeline_param->filter_flags & VA_FILTER_SCALING_MASK) == VA_FILTER_SCALING_NL_ANAMORPHIC ?
4494 PP_NV12_AVS : PP_NV12_SCALING,
4498 if (num_tmp_surfaces)
4499 i965_DestroySurfaces(ctx,
4503 intel_batchbuffer_flush(hw_context->batch);
4507 i965_proc_context_destroy(void *hw_context)
4509 struct i965_proc_context *proc_context = (struct i965_proc_context *)hw_context;
4511 i965_post_processing_context_finalize(&proc_context->pp_context);
4512 intel_batchbuffer_free(proc_context->base.batch);
4517 i965_proc_context_init(VADriverContextP ctx, struct object_config *obj_config)
4519 struct intel_driver_data *intel = intel_driver_data(ctx);
4520 struct i965_proc_context *proc_context = calloc(1, sizeof(struct i965_proc_context));
4522 proc_context->base.destroy = i965_proc_context_destroy;
4523 proc_context->base.run = i965_proc_picture;
4524 proc_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
4525 i965_post_processing_context_init(ctx, &proc_context->pp_context, proc_context->base.batch);
4527 return (struct hw_context *)proc_context;