2
*-----------------------------------------------------------------------------
5
*-----------------------------------------------------------------------------
6
* Copyright © 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 header file describes the inter-module interface for using the
29
* ring buffer. This is a legacy interface that is not strictly
30
* device-independent. It is kept here because many legacy chipsets use
32
*-----------------------------------------------------------------------------
39
#include <igd_errno.h>
42
#include <module_init.h>
51
* The rb_buffer contents should be treated as opaque but are defined
52
* here for the use in the inline functions below.
54
typedef struct _rb_buffer {
55
unsigned int id; /* ring index */
56
unsigned long size; /* size of rb in bytes */
57
unsigned long tail_off;
58
unsigned long dead_off;
60
unsigned long addr; /* starting address of rb */
61
unsigned char *virt; /* virt starting address of rb */
62
unsigned char *start; /* ring buffer start register offset */
63
unsigned char *head; /* ring buffer head register offset */
64
unsigned char *tail; /* ring buffer tail register offset */
65
unsigned char *ctrl; /* ring buffer ctrl register offset */
66
unsigned char *sync; /* used to synchronize s/w interface
67
* code via rb_sync() */
68
unsigned long next_sync;
69
int state; /* on or off state */
70
unsigned long last_head_value; /* used for checking ring buf lockup,
71
* keeps last head value*/
72
os_alarm_t last_head_time; /* used for checking ring buf lockup,
73
* keeps last head time*/
74
unsigned long reservation; /* increments upon each rb_reserver(),
75
* reset to zero upon rb_update() */
76
unsigned long sync_wrap; /* Sync number to wrap at */
77
igd_context_t * context_ptr; /*back pointer to the main driver context */
78
igd_appcontext_h appcontext; /* Appcontext that is current on the ring */
79
unsigned int skip_timeout; /* skip the timeout check */
80
unsigned int force_reset_rb; /* force a rb reset */
84
#define MODE_GET_RING(d, p) \
85
((rb_buffer_t *)((igd_display_pipe_t *)((igd_display_context_t *)d)->pipe)->queue[p])
88
* Flags used exclusively by rb_reserve()
90
#define RB_RESERVE_BLOCK 0x00000000
91
#define RB_RESERVE_NONBLOCK 0x00000001
95
* Determine how much space is available in the ring buffer.
97
unsigned long rb_avail(rb_buffer_t *buffer);
100
#define MODE_PIPE_ALLOCED(d) \
101
((igd_display_pipe_t *)((igd_display_context_t *)d)->pipe)
103
extern igd_command_t *rb_slow_reserve(rb_buffer_t *buffer,
105
unsigned long flags);
107
* For Debug do not use the inline ring functions. It makes it hard
108
* to add breakpoints.
110
#ifdef DEBUG_BUILD_TYPE
111
extern igd_command_t *rb_reserve(rb_buffer_t *buffer,
113
unsigned long flags);
115
extern int rb_update(rb_buffer_t *buffer,
116
igd_command_t *addr);
120
static __inline igd_command_t *rb_reserve(rb_buffer_t *buffer,
124
if (buffer->state == CMD_CONTROL_OFF) {
125
/* ring buffer is turned off, so don't allow a rb_reserve() */
126
buffer->context_ptr->igd_device_error_no = -IGD_ERROR_PWRDOWN;
131
* Change size to bytes for efficiency.
133
size = ((size<<2) + 7) & ~7;
135
if(buffer->reservation) {
136
buffer->avail += buffer->reservation;
138
buffer->reservation = size;
140
if(buffer->avail > size) {
141
buffer->avail -= size;
142
return (igd_command_t *)(buffer->virt + buffer->tail_off);
145
return rb_slow_reserve(buffer, size, flags);
149
static __inline int rb_update(rb_buffer_t *buffer,
152
unsigned long tail_off;
153
/* tail_off = (addr - buffer->virt); */
154
tail_off = (unsigned long)((unsigned char *)(addr) - buffer->virt);
156
buffer->reservation = 0;
157
buffer->tail_off = tail_off;
159
if(buffer->tail_off & 0x7) {
160
EMGD_WRITE32(0, buffer->virt + buffer->tail_off);
161
buffer->tail_off += 4;
165
EMGD_WRITE32(buffer->tail_off, buffer->tail);
170
static __inline igd_command_t *rb_reserve(rb_buffer_t *buffer,
177
static __inline int rb_update(rb_buffer_t *buffer,
182
#endif /* CONFIG_CMD */
187
/*----------------------------------------------------------------------------
188
* File Revision History
189
* $Id: rb.h,v 1.8 2011/02/16 17:04:48 astead Exp $
190
* $Source: /nfs/fm/proj/eia/cvsroot/koheo/linux/egd_drm/emgd/include/rb.h,v $
191
*----------------------------------------------------------------------------