Avoid depending on va_backend.h for some files
[platform/upstream/libva-intel-driver.git] / src / i965_encoder.c
1 /*
2  * Copyright © 2010 Intel Corporation
3  *
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:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
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.
23  *
24  * Authors:
25  *    Zhou Chang <chang.zhou@intel.com>
26  *
27  */
28
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <assert.h>
33
34 #include "intel_batchbuffer.h"
35 #include "intel_driver.h"
36
37 #include "i965_defines.h"
38 #include "i965_drv_video.h"
39 #include "i965_encoder.h"
40
41 static void 
42 gen6_encoder_end_picture(VADriverContextP ctx, 
43                          VAProfile profile, 
44                          union codec_state *codec_state,
45                          struct hw_context *hw_context)
46 {
47     struct gen6_encoder_context *gen6_encoder_context = (struct gen6_encoder_context *)hw_context;
48     struct encode_state *encode_state = &codec_state->enc;
49     VAStatus vaStatus;
50
51     vaStatus = gen6_vme_pipeline(ctx, profile, encode_state, gen6_encoder_context);
52
53     if (vaStatus == VA_STATUS_SUCCESS)
54         gen6_mfc_pipeline(ctx, profile, encode_state, gen6_encoder_context);
55 }
56 static void
57 gen6_encoder_context_destroy(void *hw_context)
58 {
59     struct gen6_encoder_context *gen6_encoder_context = (struct gen6_encoder_context *)hw_context;
60
61     gen6_mfc_context_destroy(&gen6_encoder_context->mfc_context);
62     gen6_vme_context_destroy(&gen6_encoder_context->vme_context);
63     intel_batchbuffer_free(gen6_encoder_context->base.batch);
64     free(gen6_encoder_context);
65 }
66
67 struct hw_context *
68 gen6_enc_hw_context_init(VADriverContextP ctx, VAProfile profile)
69 {
70     struct intel_driver_data *intel = intel_driver_data(ctx);
71     struct gen6_encoder_context *gen6_encoder_context = calloc(1, sizeof(struct gen6_encoder_context));
72
73     gen6_encoder_context->base.destroy = gen6_encoder_context_destroy;
74     gen6_encoder_context->base.run = gen6_encoder_end_picture;
75     gen6_encoder_context->base.batch = intel_batchbuffer_new(intel, I915_EXEC_RENDER);
76
77     gen6_vme_context_init(ctx, &gen6_encoder_context->vme_context);
78     gen6_mfc_context_init(ctx, &gen6_encoder_context->mfc_context);
79
80     return (struct hw_context *)gen6_encoder_context;
81 }