2 * Copyright © 2014 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.
31 #include "intel_batchbuffer.h"
32 #include "intel_driver.h"
33 #include "i965_defines.h"
34 #include "i965_structs.h"
35 #include "i965_drv_video.h"
36 #include "i965_post_processing.h"
37 #include "i965_render.h"
38 #include "intel_media.h"
40 #include "gen8_post_processing.h"
42 static const uint32_t pp_null_gen9[][4] = {
45 static const uint32_t pp_nv12_load_save_nv12_gen9[][4] = {
46 #include "shaders/post_processing/gen9/pl2_to_pl2.g9b"
49 static const uint32_t pp_nv12_load_save_pl3_gen9[][4] = {
50 #include "shaders/post_processing/gen9/pl2_to_pl3.g9b"
53 static const uint32_t pp_pl3_load_save_nv12_gen9[][4] = {
54 #include "shaders/post_processing/gen9/pl3_to_pl2.g9b"
57 static const uint32_t pp_pl3_load_save_pl3_gen9[][4] = {
58 #include "shaders/post_processing/gen9/pl3_to_pl3.g9b"
61 static const uint32_t pp_nv12_scaling_gen9[][4] = {
62 #include "shaders/post_processing/gen9/pl2_to_pl2.g9b"
65 static const uint32_t pp_nv12_avs_gen9[][4] = {
66 #include "shaders/post_processing/gen9/pl2_to_pl2.g9b"
69 static const uint32_t pp_nv12_dndi_gen9[][4] = {
72 static const uint32_t pp_nv12_dn_gen9[][4] = {
75 static const uint32_t pp_nv12_load_save_pa_gen9[][4] = {
76 #include "shaders/post_processing/gen9/pl2_to_pa.g9b"
79 static const uint32_t pp_pl3_load_save_pa_gen9[][4] = {
80 #include "shaders/post_processing/gen9/pl3_to_pa.g9b"
83 static const uint32_t pp_pa_load_save_nv12_gen9[][4] = {
84 #include "shaders/post_processing/gen9/pa_to_pl2.g9b"
87 static const uint32_t pp_pa_load_save_pl3_gen9[][4] = {
88 #include "shaders/post_processing/gen9/pa_to_pl3.g9b"
91 static const uint32_t pp_pa_load_save_pa_gen9[][4] = {
92 #include "shaders/post_processing/gen9/pa_to_pa.g9b"
95 static const uint32_t pp_rgbx_load_save_nv12_gen9[][4] = {
96 #include "shaders/post_processing/gen9/rgbx_to_nv12.g9b"
99 static const uint32_t pp_nv12_load_save_rgbx_gen9[][4] = {
100 #include "shaders/post_processing/gen9/pl2_to_rgbx.g9b"
103 static const uint32_t pp_nv12_blending_gen9[][4] = {
106 #define MAX_SCALING_SURFACES 16
108 #define DEFAULT_MOCS 0x02
109 #define SRC_MSB 0x0001
110 #define DST_MSB 0x0002
111 #define SRC_PACKED 0x0004
112 #define DST_PACKED 0x0008
113 #define PACKED_MASK 0x000C
115 #define BTI_SCALING_INPUT_Y 0
116 #define BTI_SCALING_OUTPUT_Y 8
118 struct scaling_input_parameter {
119 unsigned int input_data[5];
125 unsigned int src_msb : 1;
126 unsigned int dst_msb : 1;
127 unsigned int src_packed : 1;
128 unsigned int dst_packed : 1;
129 unsigned int reserved : 28;
134 float x_factor; // src_rect_width / dst_rect_width / Surface_width
135 float y_factor; // src_rect_height / dst_rect_height / Surface_height
138 unsigned int bti_input;
139 unsigned int bti_output;
142 static const uint32_t pp_10bit_scaling_gen9[][4] = {
143 #include "shaders/post_processing/gen9/conv_p010.g9b"
146 static struct pp_module pp_modules_gen9[] = {
149 "NULL module (for testing)",
152 sizeof(pp_null_gen9),
162 PP_NV12_LOAD_SAVE_N12,
163 pp_nv12_load_save_nv12_gen9,
164 sizeof(pp_nv12_load_save_nv12_gen9),
168 gen8_pp_plx_avs_initialize,
174 PP_NV12_LOAD_SAVE_PL3,
175 pp_nv12_load_save_pl3_gen9,
176 sizeof(pp_nv12_load_save_pl3_gen9),
179 gen8_pp_plx_avs_initialize,
185 PP_PL3_LOAD_SAVE_N12,
186 pp_pl3_load_save_nv12_gen9,
187 sizeof(pp_pl3_load_save_nv12_gen9),
191 gen8_pp_plx_avs_initialize,
197 PP_PL3_LOAD_SAVE_PL3,
198 pp_pl3_load_save_pl3_gen9,
199 sizeof(pp_pl3_load_save_pl3_gen9),
203 gen8_pp_plx_avs_initialize,
208 "NV12 Scaling module",
210 pp_nv12_scaling_gen9,
211 sizeof(pp_nv12_scaling_gen9),
215 gen8_pp_plx_avs_initialize,
223 sizeof(pp_nv12_avs_gen9),
227 gen8_pp_plx_avs_initialize,
235 sizeof(pp_nv12_dndi_gen9),
247 sizeof(pp_nv12_dn_gen9),
256 PP_NV12_LOAD_SAVE_PA,
257 pp_nv12_load_save_pa_gen9,
258 sizeof(pp_nv12_load_save_pa_gen9),
262 gen8_pp_plx_avs_initialize,
269 pp_pl3_load_save_pa_gen9,
270 sizeof(pp_pl3_load_save_pa_gen9),
274 gen8_pp_plx_avs_initialize,
280 PP_PA_LOAD_SAVE_NV12,
281 pp_pa_load_save_nv12_gen9,
282 sizeof(pp_pa_load_save_nv12_gen9),
286 gen8_pp_plx_avs_initialize,
293 pp_pa_load_save_pl3_gen9,
294 sizeof(pp_pa_load_save_pl3_gen9),
298 gen8_pp_plx_avs_initialize,
305 pp_pa_load_save_pa_gen9,
306 sizeof(pp_pa_load_save_pa_gen9),
310 gen8_pp_plx_avs_initialize,
316 PP_RGBX_LOAD_SAVE_NV12,
317 pp_rgbx_load_save_nv12_gen9,
318 sizeof(pp_rgbx_load_save_nv12_gen9),
322 gen8_pp_plx_avs_initialize,
328 PP_NV12_LOAD_SAVE_RGBX,
329 pp_nv12_load_save_rgbx_gen9,
330 sizeof(pp_nv12_load_save_rgbx_gen9),
334 gen8_pp_plx_avs_initialize,
338 static const AVSConfig gen9_avs_config = {
339 .coeff_frac_bits = 6,
340 .coeff_epsilon = 1.0f / (1U << 6),
342 .num_luma_coeffs = 8,
343 .num_chroma_coeffs = 4,
347 .y_k_h = { -2, -2, -2, -2, -2, -2, -2, -2 },
348 .y_k_v = { -2, -2, -2, -2, -2, -2, -2, -2 },
349 .uv_k_h = { -2, -2, -2, -2 },
350 .uv_k_v = { -2, -2, -2, -2 },
353 .y_k_h = { 2, 2, 2, 2, 2, 2, 2, 2 },
354 .y_k_v = { 2, 2, 2, 2, 2, 2, 2, 2 },
355 .uv_k_h = { 2, 2, 2, 2 },
356 .uv_k_v = { 2, 2, 2, 2 },
362 gen9_pp_pipeline_select(VADriverContextP ctx,
363 struct i965_post_processing_context *pp_context)
365 struct intel_batchbuffer *batch = pp_context->batch;
367 BEGIN_BATCH(batch, 1);
369 CMD_PIPELINE_SELECT |
370 PIPELINE_SELECT_MEDIA |
371 GEN9_FORCE_MEDIA_AWAKE_ON |
372 GEN9_MEDIA_DOP_GATE_OFF |
373 GEN9_PIPELINE_SELECTION_MASK |
374 GEN9_MEDIA_DOP_GATE_MASK |
375 GEN9_FORCE_MEDIA_AWAKE_MASK);
376 ADVANCE_BATCH(batch);
380 gen9_pp_state_base_address(VADriverContextP ctx,
381 struct i965_post_processing_context *pp_context)
383 struct intel_batchbuffer *batch = pp_context->batch;
385 BEGIN_BATCH(batch, 19);
386 OUT_BATCH(batch, CMD_STATE_BASE_ADDRESS | (19 - 2));
387 /* DW1 Generate state address */
388 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
391 /* DW4-5 Surface state address */
392 OUT_RELOC64(batch, pp_context->surface_state_binding_table.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY); /* Surface state base address */
393 /* DW6-7 Dynamic state address */
394 OUT_RELOC64(batch, pp_context->dynamic_state.bo, I915_GEM_DOMAIN_RENDER | I915_GEM_DOMAIN_SAMPLER,
395 0, 0 | BASE_ADDRESS_MODIFY);
397 /* DW8. Indirect object address */
398 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
401 /* DW10-11 Instruction base address */
402 OUT_RELOC64(batch, pp_context->instruction_state.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, BASE_ADDRESS_MODIFY);
404 OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY);
405 OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY);
406 OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY);
407 OUT_BATCH(batch, 0xFFFF0000 | BASE_ADDRESS_MODIFY);
409 /* Bindless surface state base address */
410 OUT_BATCH(batch, 0 | BASE_ADDRESS_MODIFY);
412 OUT_BATCH(batch, 0xfffff000);
414 ADVANCE_BATCH(batch);
418 gen9_pp_end_pipeline(VADriverContextP ctx,
419 struct i965_post_processing_context *pp_context)
421 struct intel_batchbuffer *batch = pp_context->batch;
423 BEGIN_BATCH(batch, 1);
425 CMD_PIPELINE_SELECT |
426 PIPELINE_SELECT_MEDIA |
427 GEN9_FORCE_MEDIA_AWAKE_OFF |
428 GEN9_MEDIA_DOP_GATE_ON |
429 GEN9_PIPELINE_SELECTION_MASK |
430 GEN9_MEDIA_DOP_GATE_MASK |
431 GEN9_FORCE_MEDIA_AWAKE_MASK);
432 ADVANCE_BATCH(batch);
436 gen9_pp_pipeline_setup(VADriverContextP ctx,
437 struct i965_post_processing_context *pp_context)
439 struct intel_batchbuffer *batch = pp_context->batch;
441 intel_batchbuffer_start_atomic(batch, 0x1000);
442 intel_batchbuffer_emit_mi_flush(batch);
443 gen9_pp_pipeline_select(ctx, pp_context);
444 gen9_pp_state_base_address(ctx, pp_context);
445 gen8_pp_vfe_state(ctx, pp_context);
446 gen8_pp_curbe_load(ctx, pp_context);
447 gen8_interface_descriptor_load(ctx, pp_context);
448 gen8_pp_object_walker(ctx, pp_context);
449 gen9_pp_end_pipeline(ctx, pp_context);
450 intel_batchbuffer_end_atomic(batch);
454 gen9_post_processing(VADriverContextP ctx,
455 struct i965_post_processing_context *pp_context,
456 const struct i965_surface *src_surface,
457 const VARectangle *src_rect,
458 struct i965_surface *dst_surface,
459 const VARectangle *dst_rect,
465 va_status = gen8_pp_initialize(ctx, pp_context,
473 if (va_status == VA_STATUS_SUCCESS) {
474 gen8_pp_states_setup(ctx, pp_context);
475 gen9_pp_pipeline_setup(ctx, pp_context);
482 gen9_p010_scaling_sample_state(VADriverContextP ctx,
483 struct i965_gpe_context *gpe_context,
484 VARectangle *src_rect,
485 VARectangle *dst_rect)
487 struct gen8_sampler_state *sampler_state;
489 if (gpe_context == NULL || !src_rect || !dst_rect)
491 dri_bo_map(gpe_context->dynamic_state.bo, 1);
493 if (gpe_context->dynamic_state.bo->virtual == NULL)
496 assert(gpe_context->dynamic_state.bo->virtual);
498 sampler_state = (struct gen8_sampler_state *)
499 (gpe_context->dynamic_state.bo->virtual + gpe_context->sampler_offset);
501 memset(sampler_state, 0, sizeof(*sampler_state));
503 if ((src_rect->width == dst_rect->width) &&
504 (src_rect->height == dst_rect->height)) {
505 sampler_state->ss0.min_filter = I965_MAPFILTER_NEAREST;
506 sampler_state->ss0.mag_filter = I965_MAPFILTER_NEAREST;
508 sampler_state->ss0.min_filter = I965_MAPFILTER_LINEAR;
509 sampler_state->ss0.mag_filter = I965_MAPFILTER_LINEAR;
512 sampler_state->ss3.r_wrap_mode = I965_TEXCOORDMODE_CLAMP;
513 sampler_state->ss3.s_wrap_mode = I965_TEXCOORDMODE_CLAMP;
514 sampler_state->ss3.t_wrap_mode = I965_TEXCOORDMODE_CLAMP;
516 dri_bo_unmap(gpe_context->dynamic_state.bo);
520 gen9_post_processing_context_init(VADriverContextP ctx,
522 struct intel_batchbuffer *batch)
524 struct i965_driver_data *i965 = i965_driver_data(ctx);
525 struct i965_post_processing_context *pp_context = data;
526 struct i965_gpe_context *gpe_context;
527 struct i965_kernel scaling_kernel;
529 gen8_post_processing_context_common_init(ctx, data, pp_modules_gen9, ARRAY_ELEMS(pp_modules_gen9), batch);
530 avs_init_state(&pp_context->pp_avs_context.state, &gen9_avs_config);
532 pp_context->intel_post_processing = gen9_post_processing;
534 gpe_context = &pp_context->scaling_10bit_context;
535 memset(&scaling_kernel, 0, sizeof(scaling_kernel));
536 scaling_kernel.bin = pp_10bit_scaling_gen9;
537 scaling_kernel.size = sizeof(pp_10bit_scaling_gen9);
538 gen8_gpe_load_kernels(ctx, gpe_context, &scaling_kernel, 1);
539 gpe_context->idrt_size = ALIGN(sizeof(struct gen8_interface_descriptor_data), 64);
540 gpe_context->sampler_size = ALIGN(sizeof(struct gen8_sampler_state), 64);
541 gpe_context->curbe_size = ALIGN(sizeof(struct scaling_input_parameter), 64);
542 gpe_context->curbe.length = gpe_context->curbe_size;
544 gpe_context->surface_state_binding_table.max_entries = MAX_SCALING_SURFACES;
545 gpe_context->surface_state_binding_table.binding_table_offset = 0;
546 gpe_context->surface_state_binding_table.surface_state_offset = ALIGN(MAX_SCALING_SURFACES * 4, 64);
547 gpe_context->surface_state_binding_table.length = ALIGN(MAX_SCALING_SURFACES * 4, 64) + ALIGN(MAX_SCALING_SURFACES * SURFACE_STATE_PADDED_SIZE_GEN9, 64);
549 if (i965->intel.has_bsd2)
550 gpe_context->vfe_state.max_num_threads = 300;
552 gpe_context->vfe_state.max_num_threads = 60;
554 gpe_context->vfe_state.curbe_allocation_size = 37;
555 gpe_context->vfe_state.urb_entry_size = 16;
556 gpe_context->vfe_state.num_urb_entries = 127;
557 gpe_context->vfe_state.gpgpu_mode = 0;
559 gen8_gpe_context_init(ctx, gpe_context);
560 pp_context->scaling_context_initialized = 1;
565 gen9_add_dri_buffer_2d_gpe_surface(VADriverContextP ctx,
566 struct i965_gpe_context *gpe_context,
568 unsigned int bo_offset,
572 int is_media_block_rw,
577 struct i965_gpe_resource gpe_resource;
578 struct i965_gpe_surface gpe_surface;
580 i965_gpe_dri_object_to_2d_gpe_resource(&gpe_resource, bo, width, height, pitch);
581 memset(&gpe_surface, 0, sizeof(gpe_surface));
582 gpe_surface.gpe_resource = &gpe_resource;
583 gpe_surface.is_2d_surface = 1;
584 gpe_surface.is_media_block_rw = !!is_media_block_rw;
585 gpe_surface.cacheability_control = DEFAULT_MOCS;
586 gpe_surface.format = format;
587 gpe_surface.is_override_offset = 1;
588 gpe_surface.offset = bo_offset;
589 gpe_surface.is_16bpp = is_10bit;
591 gen9_gpe_context_add_surface(gpe_context, &gpe_surface, index);
593 i965_free_gpe_resource(&gpe_resource);
597 gen9_run_kernel_media_object_walker(VADriverContextP ctx,
598 struct intel_batchbuffer *batch,
599 struct i965_gpe_context *gpe_context,
600 struct gpe_media_object_walker_parameter *param)
602 if (!batch || !gpe_context || !param)
605 intel_batchbuffer_start_atomic(batch, 0x1000);
607 intel_batchbuffer_emit_mi_flush(batch);
609 gen9_gpe_pipeline_setup(ctx, gpe_context, batch);
610 gen9_gpe_media_object_walker(ctx, gpe_context, batch, param);
611 gen8_gpe_media_state_flush(ctx, gpe_context, batch);
613 gen9_gpe_pipeline_end(ctx, gpe_context, batch);
615 intel_batchbuffer_end_atomic(batch);
617 intel_batchbuffer_flush(batch);
622 pp_get_surface_fourcc(VADriverContextP ctx, struct i965_surface *surface)
626 if (surface->type == I965_SURFACE_TYPE_IMAGE) {
627 struct object_image *obj_image = (struct object_image *)surface->base;
628 fourcc = obj_image->image.format.fourcc;
630 struct object_surface *obj_surface = (struct object_surface *)surface->base;
631 fourcc = obj_surface->fourcc;
638 gen9_gpe_context_p010_scaling_curbe(VADriverContextP ctx,
639 struct i965_gpe_context *gpe_context,
640 VARectangle *src_rect,
641 struct i965_surface *src_surface,
642 VARectangle *dst_rect,
643 struct i965_surface *dst_surface)
645 struct scaling_input_parameter *scaling_curbe;
646 float src_width, src_height;
650 if ((gpe_context == NULL) ||
651 (src_rect == NULL) || (src_surface == NULL) ||
652 (dst_rect == NULL) || (dst_surface == NULL))
655 scaling_curbe = gen8p_gpe_context_map_curbe(gpe_context);
660 memset(scaling_curbe, 0, sizeof(struct scaling_input_parameter));
662 scaling_curbe->bti_input = BTI_SCALING_INPUT_Y;
663 scaling_curbe->bti_output = BTI_SCALING_OUTPUT_Y;
665 /* As the src_rect/dst_rect is already checked, it is skipped.*/
666 scaling_curbe->x_dst = dst_rect->x;
667 scaling_curbe->y_dst = dst_rect->y;
669 src_width = src_rect->x + src_rect->width;
670 src_height = src_rect->y + src_rect->height;
672 scaling_curbe->inv_width = 1 / src_width;
673 scaling_curbe->inv_height = 1 / src_height;
675 coeff = (float) (src_rect->width) / dst_rect->width;
676 scaling_curbe->x_factor = coeff / src_width;
677 scaling_curbe->x_orig = (float)(src_rect->x) / src_width;
679 coeff = (float) (src_rect->height) / dst_rect->height;
680 scaling_curbe->y_factor = coeff / src_height;
681 scaling_curbe->y_orig = (float)(src_rect->y) / src_height;
683 fourcc = pp_get_surface_fourcc(ctx, src_surface);
684 if (fourcc == VA_FOURCC_P010) {
685 scaling_curbe->dw7.src_packed = 1;
686 scaling_curbe->dw7.src_msb = 1;
688 /* I010 will use LSB */
690 fourcc = pp_get_surface_fourcc(ctx, dst_surface);
692 if (fourcc == VA_FOURCC_P010) {
693 scaling_curbe->dw7.dst_packed = 1;
694 scaling_curbe->dw7.dst_msb = 1;
696 /* I010 will use LSB */
698 gen8p_gpe_context_unmap_curbe(gpe_context);
702 gen9_pp_context_get_surface_conf(VADriverContextP ctx,
703 struct i965_surface *surface,
711 if (!rect || !surface || !width || !height || !pitch || !bo_offset)
714 if (surface->base == NULL)
717 fourcc = pp_get_surface_fourcc(ctx, surface);
718 if (surface->type == I965_SURFACE_TYPE_SURFACE) {
719 struct object_surface *obj_surface;
721 obj_surface = (struct object_surface *)surface->base;
722 width[0] = MIN(rect->x + rect->width, obj_surface->orig_width);
723 height[0] = MIN(rect->y + rect->height, obj_surface->orig_height);
724 pitch[0] = obj_surface->width;
727 if (fourcc == VA_FOURCC_P010) {
728 width[1] = width[0] / 2;
729 height[1] = height[0] / 2;
730 pitch[1] = obj_surface->cb_cr_pitch;
731 bo_offset[1] = obj_surface->width * obj_surface->y_cb_offset;
734 width[1] = width[0] / 2;
735 height[1] = height[0] / 2;
736 pitch[1] = obj_surface->cb_cr_pitch;
737 bo_offset[1] = obj_surface->width * obj_surface->y_cb_offset;
738 width[2] = width[0] / 2;
739 height[2] = height[0] / 2;
740 pitch[2] = obj_surface->cb_cr_pitch;
741 bo_offset[2] = obj_surface->width * obj_surface->y_cr_offset;
745 struct object_image *obj_image;
747 obj_image = (struct object_image *)surface->base;
749 width[0] = MIN(rect->x + rect->width, obj_image->image.width);
750 height[0] = MIN(rect->y + rect->height, obj_image->image.height);
751 pitch[0] = obj_image->image.pitches[0];
752 bo_offset[0] = obj_image->image.offsets[0];
754 if (fourcc == VA_FOURCC_P010) {
755 width[1] = width[0] / 2;
756 height[1] = height[0] / 2;
757 pitch[1] = obj_image->image.pitches[1];
758 bo_offset[1] = obj_image->image.offsets[1];
761 width[1] = width[0] / 2;
762 height[1] = height[0] / 2;
763 pitch[1] = obj_image->image.pitches[1];
764 bo_offset[1] = obj_image->image.offsets[1];
765 width[2] = width[0] / 2;
766 height[2] = height[0] / 2;
767 pitch[2] = obj_image->image.pitches[2];
768 bo_offset[2] = obj_image->image.offsets[2];
777 gen9_gpe_context_p010_scaling_surfaces(VADriverContextP ctx,
778 struct i965_gpe_context *gpe_context,
779 VARectangle *src_rect,
780 struct i965_surface *src_surface,
781 VARectangle *dst_rect,
782 struct i965_surface *dst_surface)
785 int width[3], height[3], pitch[3], bo_offset[3];
787 struct object_surface *obj_surface;
788 struct object_image *obj_image;
791 if ((gpe_context == NULL) ||
792 (src_rect == NULL) || (src_surface == NULL) ||
793 (dst_rect == NULL) || (dst_surface == NULL))
796 if (src_surface->base == NULL || dst_surface->base == NULL)
799 fourcc = pp_get_surface_fourcc(ctx, src_surface);
801 if (src_surface->type == I965_SURFACE_TYPE_SURFACE) {
802 obj_surface = (struct object_surface *)src_surface->base;
803 bo = obj_surface->bo;
805 obj_image = (struct object_image *)src_surface->base;
810 if (gen9_pp_context_get_surface_conf(ctx, src_surface, src_rect,
811 width, height, pitch,
813 bti = BTI_SCALING_INPUT_Y;
815 gen9_add_dri_buffer_2d_gpe_surface(ctx, gpe_context, bo,
819 I965_SURFACEFORMAT_R16_UNORM,
821 if (fourcc == VA_FOURCC_P010) {
822 gen9_add_dri_buffer_2d_gpe_surface(ctx, gpe_context, bo,
826 I965_SURFACEFORMAT_R16G16_UNORM,
829 gen9_add_dri_buffer_2d_gpe_surface(ctx, gpe_context, bo,
833 I965_SURFACEFORMAT_R16_UNORM,
836 gen9_add_dri_buffer_2d_gpe_surface(ctx, gpe_context, bo,
840 I965_SURFACEFORMAT_R16_UNORM,
845 fourcc = pp_get_surface_fourcc(ctx, dst_surface);
847 if (dst_surface->type == I965_SURFACE_TYPE_SURFACE) {
848 obj_surface = (struct object_surface *)dst_surface->base;
849 bo = obj_surface->bo;
851 obj_image = (struct object_image *)dst_surface->base;
855 if (gen9_pp_context_get_surface_conf(ctx, dst_surface, dst_rect,
856 width, height, pitch,
858 bti = BTI_SCALING_OUTPUT_Y;
860 gen9_add_dri_buffer_2d_gpe_surface(ctx, gpe_context, bo,
864 I965_SURFACEFORMAT_R16_UINT,
866 if (fourcc == VA_FOURCC_P010) {
867 gen9_add_dri_buffer_2d_gpe_surface(ctx, gpe_context, bo,
869 width[1] * 2, height[1],
871 I965_SURFACEFORMAT_R16_UINT,
874 gen9_add_dri_buffer_2d_gpe_surface(ctx, gpe_context, bo,
878 I965_SURFACEFORMAT_R16_UINT,
881 gen9_add_dri_buffer_2d_gpe_surface(ctx, gpe_context, bo,
885 I965_SURFACEFORMAT_R16_UINT,
894 gen9_p010_scaling_post_processing(
895 VADriverContextP ctx,
896 struct i965_post_processing_context *pp_context,
897 struct i965_surface *src_surface,
898 VARectangle *src_rect,
899 struct i965_surface *dst_surface,
900 VARectangle *dst_rect)
902 struct i965_gpe_context *gpe_context;
903 struct gpe_media_object_walker_parameter media_object_walker_param;
904 struct intel_vpp_kernel_walker_parameter kernel_walker_param;
906 if (!pp_context || !src_surface || !src_rect || !dst_surface || !dst_rect)
907 return VA_STATUS_ERROR_INVALID_PARAMETER;
909 if (!pp_context->scaling_context_initialized)
910 return VA_STATUS_ERROR_UNIMPLEMENTED;
912 gpe_context = &pp_context->scaling_10bit_context;
914 gen8_gpe_context_init(ctx, gpe_context);
915 gen9_p010_scaling_sample_state(ctx, gpe_context, src_rect, dst_rect);
916 gen9_gpe_reset_binding_table(ctx, gpe_context);
917 gen9_gpe_context_p010_scaling_curbe(ctx, gpe_context,
918 src_rect, src_surface,
919 dst_rect, dst_surface);
921 gen9_gpe_context_p010_scaling_surfaces(ctx, gpe_context,
922 src_rect, src_surface,
923 dst_rect, dst_surface);
925 gen8_gpe_setup_interface_data(ctx, gpe_context);
927 memset(&kernel_walker_param, 0, sizeof(kernel_walker_param));
928 kernel_walker_param.resolution_x = ALIGN(dst_rect->width, 16) >> 4;
929 kernel_walker_param.resolution_y = ALIGN(dst_rect->height, 16) >> 4;
930 kernel_walker_param.no_dependency = 1;
932 intel_vpp_init_media_object_walker_parameter(&kernel_walker_param, &media_object_walker_param);
934 gen9_run_kernel_media_object_walker(ctx, pp_context->batch,
936 &media_object_walker_param);
938 return VA_STATUS_SUCCESS;