2 *-----------------------------------------------------------------------------
3 * Filename: appcontext_plb.c
5 *-----------------------------------------------------------------------------
6 * Copyright (c) 2002-2010, Intel Corporation.
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 *-----------------------------------------------------------------------------
28 * This file inplements the IGD interface for the context module. This
29 * includes functions that handle hardware context swapping and state
30 * variable management.
31 *-----------------------------------------------------------------------------
36 #include <igd_appcontext.h>
39 #include <igd_render.h>
40 #include <igd_errno.h>
44 #include <mode_access.h>
51 #include <plb/appcontext.h>
52 #include <plb/instr.h>
53 #include <plb/state3d_plb.h>
55 #include "../cmn/appcontext_dispatch.h"
58 * @addtogroup state_group
63 * Prototype these here because they are only needed by appcontext.c
64 * and putting them in state2d.h would cause a circular dependency.
67 static igd_appcontext_h igd_appcontext_alloc_plb(
68 igd_display_h display_handle,
71 static void igd_appcontext_free_plb(
72 igd_display_h display_h,
74 igd_appcontext_h appcontext_handle);
75 static int appcontext_init_plb(igd_context_t *context);
76 static void appcontext_shutdown_plb(igd_context_t *context);
78 static appcontext_table_t appcontext_table_plb[] = {
82 appcontext_dispatch_t appcontext_dispatch_plb = {
84 appcontext_shutdown_plb,
85 igd_appcontext_alloc_plb,
86 igd_appcontext_free_plb,
94 * @return 0 on success
95 * @return -IGD_ERROR_NOMEM on failure
97 static int state2d_init_plb(appcontext_t *appcontext)
100 appcontext->state2d = OS_ALLOC(sizeof(state2d_t));
101 if(!appcontext->state2d) {
102 return -IGD_ERROR_NOMEM;
105 STATE2D(appcontext)->clip_status = IGD_CLIP_DISABLED;
106 STATE2D(appcontext)->dest_rect.x1 = 0;
107 STATE2D(appcontext)->dest_rect.y1 = 0;
108 STATE2D(appcontext)->dest_rect.x2 = 0;
109 STATE2D(appcontext)->dest_rect.y2 = 0;
120 static int state2d_shutdown_plb(appcontext_t *appcontext)
122 if(appcontext->state2d) {
123 OS_FREE(appcontext->state2d);
126 appcontext->state2d = NULL;
133 * @param display_handle
137 * @return appcontext_h on success
138 * @return NULL on failure
140 static igd_appcontext_h igd_appcontext_alloc_plb(
141 igd_display_h display_handle,
145 appcontext_t *appcontext;
147 /* A proper appcontext is not required for Poulsbo
148 * as a result, we'll allocate it and have it set to NULL
150 appcontext = OS_ALLOC(sizeof(appcontext_t));
152 EMGD_ERROR ("OS_ALLOC appcontext failed\n");
156 OS_MEMSET(appcontext, 0, sizeof(appcontext_t));
157 appcontext->state2d = NULL;
159 if (flags & IGD_CONTEXT_STATE_2D) {
160 if (state2d_init_plb(appcontext)) {
161 igd_appcontext_free_plb(display_handle, priority, appcontext);
170 static void igd_appcontext_free_plb(
171 igd_display_h display_h,
173 igd_appcontext_h appcontext_handle)
176 appcontext_t *appcontext = (appcontext_t *)appcontext_handle;
178 /* Free the appcontext struct */
180 state2d_shutdown_plb(appcontext);
182 OS_FREE(appcontext_handle);
192 static int appcontext_init_plb(igd_context_t *context)
203 static void appcontext_shutdown_plb(igd_context_t *context)