aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/emgd/emgd/video/overlay/cmn/micro_ovl.c
blob: 24c5dc9109acab26ef3c45cd917140684c180438 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/* -*- pse-c -*-
 *-----------------------------------------------------------------------------
 * Filename: micro_ovl.c
 * $Revision: 1.10 $
 *-----------------------------------------------------------------------------
 * Copyright © 2002-2010, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms and conditions of the GNU General Public License,
 * version 2, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *-----------------------------------------------------------------------------
 * Description:
 *  
 *-----------------------------------------------------------------------------
 */

#define MODULE_NAME hal.overlay

#include <context.h>
#include <memory.h>
#include <dsp.h>
#include <io.h>

#include <igd_mode.h>
#include <igd_gmm.h>
//#include <igd_ovl.h>
#include <igd_pwr.h>
#include <igd_render.h>
#include <igd_blend.h>

#include <general.h>
#include <mode_access.h>
#include <dispatch.h>
#include <intelpci.h>

#include "ovl_dispatch.h"
#include "ovl_virt.h"

/*
 * TODO: If there is micro overlay for device dependent layer
 * modify extern below to the correct micro device dispatch
 * Only two micro overlay existing is for Plb and Ctg
 */

extern ovl_dispatch_t ovl_micro_dispatch_plb[];

static dispatch_table_t ovl_micro_dispatch_list[] = {
/*
 * TODO: Fix this.
 *  * This table would point the micro dispatch tables.
 *  For now, other than Plb ,refer the micro dispatch
 *  to the original table
 * */

#ifdef CONFIG_PLB
	{PCI_DEVICE_ID_VGA_PLB, &ovl_micro_dispatch_plb},
#endif
#ifdef CONFIG_TNC
	{PCI_DEVICE_ID_VGA_TNC, &ovl_micro_dispatch_plb},
#endif
	{0, NULL}
};
extern int ovl_full_init(igd_context_t *context, igd_param_t *params,ovl_context_t *ovl_context);

#ifndef CONFIG_MICRO_OVERLAY
#define OVL_FULL_INIT(a, b, c) ovl_full_init(a, b, c)
#else
#define OVL_FULL_INIT(a, b, c) 1
#endif

extern ovl_context_t ovl_context[1];
static int igd_micro_alter_ovl(igd_display_h display_h,
	igd_appcontext_h     appcontext_h,
	igd_surface_t       *src_surf,
	igd_rect_t          *src_rect,
	igd_rect_t          *dest_rect,
	igd_ovl_info_t      *ovl_info,
	unsigned int         flags)
{
	igd_display_context_t *display =
		(igd_display_context_t *)display_h;
	ovl_dispatch_t    *ovl_dispatch =
		(ovl_dispatch_t *)ovl_context->dispatch;

	igd_display_context_t *ovl_display;

	int ret = 0;

	EMGD_TRACE_ENTER;

	ovl_display = display;

	/* Call family dependent overlay function to alter the overlay. */
	ret = ovl_dispatch->alter_ovl(
				ovl_display, src_surf, src_rect,
				dest_rect, ovl_info, flags);

	if (ret != IGD_SUCCESS) {
		EMGD_ERROR("Error micro alter overlay\n");
		/* Turn the overlay off when there is an error */
		ovl_dispatch->alter_ovl(ovl_display,
					NULL, NULL, NULL, NULL, IGD_OVL_ALTER_OFF);
	}

	EMGD_TRACE_EXIT;
	return ret;
}

int _overlay_init(igd_context_t *context, igd_param_t *params)
{

	EMGD_TRACE_ENTER;

	/* Ensure the device context pointer is valid */
	if(!context){
		EMGD_ERROR_EXIT("Error: Null context");
		return -IGD_ERROR_INVAL;
	}

	/* Clear the allocated memory for overlay context */
	OS_MEMSET((void *)ovl_context, 0, sizeof(ovl_context_t));

	/* Get overlay's dispatch table */
	ovl_context->dispatch = (ovl_dispatch_t (*)[])dispatch_acquire(context,
		ovl_micro_dispatch_list);
	if(!ovl_context->dispatch) {
		EMGD_ERROR_EXIT("Error: Unsupported Device");
		return -IGD_ERROR_NODEV;
	}


	/* Hook up the IGD dispatch table entries for overlay
	 * Alter has a common function, query can call the family function
	 * directly */
	context->dispatch.alter_ovl = igd_micro_alter_ovl;
	context->dispatch.query_ovl = NULL;
	context->dispatch.query_max_size_ovl = NULL;
	context->mod_dispatch.overlay_shutdown = NULL;

	if (OVL_FULL_INIT(context, params, ovl_context)) {
		/*
		 * Even if full init failed we can still use the micro-gmm
		 */
		EMGD_DEBUG("Full overlay did not initialize, using micro-overlay");

	}

	EMGD_TRACE_EXIT;
	return IGD_SUCCESS;
}