Commit 9ac07d29 authored by Austin Yuan's avatar Austin Yuan

Apply the patch from Nanhai to support MPEG2 VLD on Intel integrated G45 graphics

Signed-off-by: default avatarAustin Yuan <shengquan.yuan@intel.com>
parent 8de7d122
......@@ -21,7 +21,7 @@
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src dummy_drv_video test
SUBDIRS = src dummy_drv_video test i965_drv_video
pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libva.pc
......
......@@ -25,7 +25,7 @@ AC_INIT([libva], 0.30.4, [waldo.bastian@intel.com], libva)
AC_CONFIG_SRCDIR([Makefile.am])
AM_INIT_AUTOMAKE([dist-bzip2])
AM_CONFIG_HEADER([src/config.h])
AM_CONFIG_HEADER([config.h])
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
......@@ -39,6 +39,9 @@ PKG_CHECK_MODULES([XEXT],[xext])
PKG_CHECK_MODULES([DRM], [libdrm])
PKG_CHECK_MODULES(LIBDRM_DEPS, [libdrm])
AC_CHECK_PROG(gen4asm, [intel-gen4asm], yes, no)
AM_CONDITIONAL(HAVE_GEN4ASM, test x$gen4asm = xyes)
# We only need the headers, we don't link against the DRM libraries
LIBVA_CFLAGS="$LIBDRM_DEPS_CFLAGS"
AC_SUBST(LIBVA_CFLAGS)
......@@ -53,5 +56,11 @@ AC_OUTPUT([
src/X11/Makefile
dummy_drv_video/Makefile
test/Makefile
i965_drv_video/Makefile
i965_drv_video/shaders/Makefile
i965_drv_video/shaders/mpeg2/Makefile
i965_drv_video/shaders/mpeg2/vld/Makefile
i965_drv_video/shaders/render/Makefile
libva.pc
])
# Copyright (c) 2007 Intel Corporation. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sub license, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice (including the
# next paragraph) shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
# IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
SUBDIRS = shaders
AM_CFLAGS = -Wall -I$(top_srcdir)/src -I$(top_srcdir)/common -I$(top_srcdir)/intel @DRM_CFLAGS@ -DIN_LIBVA
i965_drv_video_la_LTLIBRARIES = i965_drv_video.la
i965_drv_video_ladir = $(libdir)/dri
i965_drv_video_la_LDFLAGS = -module -avoid-version -no-undefined -Wl,--no-undefined @DRM_LIBS@ -ldrm_intel
i965_drv_video_la_LIBADD = ../src/libva.la -lpthread
i965_drv_video_la_SOURCES = \
object_heap.c \
intel_batchbuffer.c \
intel_memman.c \
intel_driver.c \
i965_media.c \
i965_media_mpeg2.c \
i965_render.c \
i965_drv_video.c
This diff is collapsed.
This diff is collapsed.
/*
* Copyright 2009 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Xiang Haihao <haihao.xiang@intel.com>
* Zou Nan hai <nanhai.zou@intel.com>
*
*/
#ifndef _I965_DRV_VIDEO_H_
#define _I965_DRV_VIDEO_H_
#include "va.h"
#include "object_heap.h"
#include "intel_driver.h"
#include "i965_media.h"
#include "i965_render.h"
#define I965_MAX_PROFILES 11
#define I965_MAX_ENTRYPOINTS 5
#define I965_MAX_CONFIG_ATTRIBUTES 10
#define I965_MAX_IMAGE_FORMATS 10
#define I965_MAX_SUBPIC_FORMATS 4
#define I965_MAX_DISPLAY_ATTRIBUTES 4
#define I965_STR_VENDOR "i965 Driver 0.1"
struct buffer_store
{
unsigned char *buffer;
dri_bo *bo;
int ref_count;
};
struct object_config
{
struct object_base base;
VAProfile profile;
VAEntrypoint entrypoint;
VAConfigAttrib attrib_list[I965_MAX_CONFIG_ATTRIBUTES];
int num_attribs;
};
struct decode_state
{
struct buffer_store *pic_param;
struct buffer_store *slice_param;
struct buffer_store *iq_matrix;
struct buffer_store *bit_plane;
struct buffer_store *slice_data;
VASurfaceID current_render_target;
int num_slices;
};
struct object_context
{
struct object_base base;
VAContextID context_id;
VAConfigID config_id;
VASurfaceID *render_targets;
int num_render_targets;
int picture_width;
int picture_height;
int flags;
struct decode_state decode_state;
};
struct object_surface
{
struct object_base base;
VASurfaceStatus status;
VASubpictureID subpic;
int width;
int height;
int size;
dri_bo *bo;
};
struct object_buffer
{
struct object_base base;
struct buffer_store *buffer_store;
int max_num_elements;
int num_elements;
int size_element;
VABufferType type;
};
struct object_image
{
struct object_base base;
int width;
int height;
int size;
dri_bo *bo;
};
struct object_subpic
{
struct object_base base;
VAImageID image;
int dstx;
int dsty;
int width;
int height;
unsigned char palette[3][16];
dri_bo *bo;
};
struct i965_driver_data
{
struct intel_driver_data intel;
struct object_heap config_heap;
struct object_heap context_heap;
struct object_heap surface_heap;
struct object_heap buffer_heap;
struct object_heap image_heap;
struct object_heap subpic_heap;
struct i965_media_state media_state;
struct i965_render_state render_state;
};
#define NEW_CONFIG_ID() object_heap_allocate(&i965->config_heap);
#define NEW_CONTEXT_ID() object_heap_allocate(&i965->context_heap);
#define NEW_SURFACE_ID() object_heap_allocate(&i965->surface_heap);
#define NEW_BUFFER_ID() object_heap_allocate(&i965->buffer_heap);
#define NEW_IMAGE_ID() object_heap_allocate(&i965->image_heap);
#define NEW_SUBPIC_ID() object_heap_allocate(&i965->subpic_heap);
#define CONFIG(id) ((struct object_config *)object_heap_lookup(&i965->config_heap, id))
#define CONTEXT(id) ((struct object_context *)object_heap_lookup(&i965->context_heap, id))
#define SURFACE(id) ((struct object_surface *)object_heap_lookup(&i965->surface_heap, id))
#define BUFFER(id) ((struct object_buffer *)object_heap_lookup(&i965->buffer_heap, id))
#define IMAGE(id) ((struct object_image *)object_heap_lookup(&i965->image_heap, id))
#define SUBPIC(id) ((struct object_subpic *)object_heap_lookup(&i965->subpic_heap, id))
#define FOURCC_IA44 0x34344149
#define FOURCC_AI44 0x34344941
#define STRIDE(w) (((w) + 0xf) & ~0xf)
#define SIZE_YUV420(w, h) (h * (STRIDE(w) + STRIDE(w >> 1)))
static INLINE struct i965_driver_data *
i965_driver_data(VADriverContextP ctx)
{
return (struct i965_driver_data *)(ctx->pDriverData);
}
#endif /* _I965_DRV_VIDEO_H_ */
# i965_drv_video.la - a libtool library file
# Generated by ltmain.sh (GNU libtool) 2.2.2 Debian-2.2.2-1
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='i965_drv_video.so'
# Names of this library.
library_names='i965_drv_video.so i965_drv_video.so i965_drv_video.so'
# The name of the static archive.
old_library=''
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=''
# Libraries that this one depends upon.
dependency_libs=' -L/opt/X11R7/lib /opt/X11R7/lib/libdrm_intel.la /opt/X11R7/lib/libdrm.la -lrt /home/znh/libva.old/src/libva.la -lX11 -lXext /opt/X11R7/lib/libXext.la /opt/X11R7/lib/libX11.la /opt/X11R7/lib/libXdmcp.la -ldl /opt/X11R7/lib/libXau.la -lpthread'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for i965_drv_video.
current=0
age=0
revision=0
# Is this an already installed library?
installed=no
# Should we warn about portability when linking against -modules?
shouldnotlink=yes
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='/opt/X11R7/lib/dri'
relink_command="(cd /home/znh/libva.old/i965_drv_video; /bin/sh /home/znh/libva.old/libtool --tag CC --mode=relink gcc -Wall -I../src -I../common -I../intel -I/opt/X11R7/include -I/opt/X11R7/include/drm -DIN_LIBVA -g -O2 -module -avoid-version -no-undefined -Wl,--no-undefined -L/opt/X11R7/lib -ldrm -ldrm_intel -o i965_drv_video.la -rpath /opt/X11R7/lib/dri object_heap.lo intel_batchbuffer.lo intel_memman.lo intel_driver.lo i965_media.lo i965_media_mpeg2.lo i965_render.lo i965_drv_video.lo ../src/libva.la -lpthread @inst_prefix_dir@)"
/*
* Copyright 2009 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Xiang Haihao <haihao.xiang@intel.com>
* Zou Nan hai <nanhai.zou@intel.com>
*
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "va_backend.h"
#include "intel_batchbuffer.h"
#include "intel_driver.h"
#include "i965_defines.h"
#include "i965_media_mpeg2.h"
#include "i965_media.h"
#include "i965_drv_video.h"
static void
i965_media_pipeline_select(VADriverContextP ctx)
{
BEGIN_BATCH(ctx, 1);
OUT_BATCH(ctx, CMD_PIPELINE_SELECT | PIPELINE_SELECT_MEDIA);
ADVANCE_BATCH(ctx);
}
static void
i965_media_urb_layout(VADriverContextP ctx)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state;
unsigned int vfe_fence, cs_fence;
vfe_fence = media_state->urb.cs_start;
cs_fence = URB_SIZE((&i965->intel));
BEGIN_BATCH(ctx, 3);
OUT_BATCH(ctx, CMD_URB_FENCE | UF0_VFE_REALLOC | UF0_CS_REALLOC | 1);
OUT_BATCH(ctx, 0);
OUT_BATCH(ctx,
(vfe_fence << UF2_VFE_FENCE_SHIFT) | /* VFE_SIZE */
(cs_fence << UF2_CS_FENCE_SHIFT)); /* CS_SIZE */
ADVANCE_BATCH(ctx);
}
static void
i965_media_state_base_address(VADriverContextP ctx)
{
BEGIN_BATCH(ctx, 6);
OUT_BATCH(ctx, CMD_STATE_BASE_ADDRESS | 4);
OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY);
OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY);
OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY);
OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY);
OUT_BATCH(ctx, 0 | BASE_ADDRESS_MODIFY);
ADVANCE_BATCH(ctx);
}
static void
i965_media_state_pointers(VADriverContextP ctx)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state;
BEGIN_BATCH(ctx, 3);
OUT_BATCH(ctx, CMD_MEDIA_STATE_POINTERS | 1);
if (media_state->extended_state.enabled)
OUT_RELOC(ctx, media_state->extended_state.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 1);
else
OUT_BATCH(ctx, 0);
OUT_RELOC(ctx, media_state->vfe_state.bo, I915_GEM_DOMAIN_INSTRUCTION, 0, 0);
ADVANCE_BATCH(ctx);
}
static void
i965_media_cs_urb_layout(VADriverContextP ctx)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state;
BEGIN_BATCH(ctx, 2);
OUT_BATCH(ctx, CMD_CS_URB_STATE | 0);
OUT_BATCH(ctx,
((media_state->urb.size_cs_entry - 1) << 4) | /* URB Entry Allocation Size */
(media_state->urb.num_cs_entries << 0)); /* Number of URB Entries */
ADVANCE_BATCH(ctx);
}
static void
i965_media_pipeline_state(VADriverContextP ctx)
{
i965_media_state_base_address(ctx);
i965_media_state_pointers(ctx);
i965_media_cs_urb_layout(ctx);
}
static void
i965_media_constant_buffer(VADriverContextP ctx, struct decode_state *decode_state)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state;
BEGIN_BATCH(ctx, 2);
OUT_BATCH(ctx, CMD_CONSTANT_BUFFER | (1 << 8) | (2 - 2));
OUT_RELOC(ctx, media_state->curbe.bo,
I915_GEM_DOMAIN_INSTRUCTION, 0,
media_state->urb.size_cs_entry - 1);
ADVANCE_BATCH(ctx);
}
static void
i965_media_pipeline_setup(VADriverContextP ctx, struct decode_state *decode_state)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state;
intel_batchbuffer_start_atomic(ctx, 0x1000);
intel_batchbuffer_emit_mi_flush(ctx); /* step 1 */
i965_media_pipeline_select(ctx); /* step 2 */
i965_media_urb_layout(ctx); /* step 3 */
i965_media_pipeline_state(ctx); /* step 4 */
i965_media_constant_buffer(ctx, decode_state); /* step 5 */
assert(media_state->media_objects);
media_state->media_objects(ctx, decode_state); /* step 6 */
intel_batchbuffer_end_atomic(ctx);
}
static void
i965_media_decode_init(VADriverContextP ctx, VAProfile profile)
{
int i;
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state;
dri_bo *bo;
/* constant buffer */
dri_bo_unreference(media_state->curbe.bo);
bo = dri_bo_alloc(i965->intel.bufmgr,
"constant buffer",
4096, 64);
assert(bo);
media_state->curbe.bo = bo;
/* surface state */
for (i = 0; i < MAX_MEDIA_SURFACES; i++) {
dri_bo_unreference(media_state->surface_state[i].bo);
media_state->surface_state[i].bo = NULL;
}
/* binding table */
dri_bo_unreference(media_state->binding_table.bo);
bo = dri_bo_alloc(i965->intel.bufmgr,
"binding table",
MAX_MEDIA_SURFACES * sizeof(unsigned int), 32);
assert(bo);
media_state->binding_table.bo = bo;
/* interface descriptor remapping table */
dri_bo_unreference(media_state->idrt.bo);
bo = dri_bo_alloc(i965->intel.bufmgr,
"interface discriptor",
MAX_INTERFACE_DESC * sizeof(struct i965_interface_descriptor), 16);
assert(bo);
media_state->idrt.bo = bo;
/* vfe state */
dri_bo_unreference(media_state->vfe_state.bo);
bo = dri_bo_alloc(i965->intel.bufmgr,
"vfe state",
sizeof(struct i965_vfe_state), 32);
assert(bo);
media_state->vfe_state.bo = bo;
/* extended state */
media_state->extended_state.enabled = 0;
switch (profile) {
case VAProfileMPEG2Simple:
case VAProfileMPEG2Main:
i965_media_mpeg2_decode_init(ctx);
break;
default:
assert(0);
break;
}
}
void
i965_media_decode_picture(VADriverContextP ctx,
VAProfile profile,
struct decode_state *decode_state)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state;
i965_media_decode_init(ctx, profile);
assert(media_state->states_setup);
media_state->states_setup(ctx, decode_state);
i965_media_pipeline_setup(ctx, decode_state);
intel_batchbuffer_flush(ctx);
}
Bool
i965_media_init(VADriverContextP ctx)
{
i965_media_mpeg2_init(ctx);
return True;
}
Bool
i965_media_terminate(VADriverContextP ctx)
{
struct i965_driver_data *i965 = i965_driver_data(ctx);
struct i965_media_state *media_state = &i965->media_state;
int i;
for (i = 0; i < MAX_MEDIA_SURFACES; i++) {
dri_bo_unreference(media_state->surface_state[i].bo);
media_state->surface_state[i].bo = NULL;
}
dri_bo_unreference(media_state->extended_state.bo);
media_state->extended_state.bo = NULL;
dri_bo_unreference(media_state->vfe_state.bo);
media_state->vfe_state.bo = NULL;
dri_bo_unreference(media_state->idrt.bo);
media_state->idrt.bo = NULL;
dri_bo_unreference(media_state->binding_table.bo);
media_state->binding_table.bo = NULL;
dri_bo_unreference(media_state->curbe.bo);
media_state->curbe.bo = NULL;
i965_media_mpeg2_ternimate(ctx);
return True;
}
/*
* Copyright © 2009 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Xiang Haihao <haihao.xiang@intel.com>
* Zou Nan hai <nanhai.zou@intel.com>
*
*/
#ifndef _I965_MEDIA_H_
#define _I965_MEDIA_H_
#include <xf86drm.h>
#include <drm.h>
#include <i915_drm.h>
#include <intel_bufmgr.h>
#include "i965_structs.h"
#define MAX_INTERFACE_DESC 16
#define MAX_MEDIA_SURFACES 32
#define MPEG_TOP_FIELD 1
#define MPEG_BOTTOM_FIELD 2
#define MPEG_FRAME 3
struct decode_state;
struct media_kernel
{
char *name;
int interface;
unsigned int (*bin)[4];
int size;
dri_bo *bo;
};
struct i965_media_state
{
struct {
dri_bo *bo;
} surface_state[MAX_MEDIA_SURFACES];
struct {
dri_bo *bo;
} binding_table;
struct {
dri_bo *bo;
} idrt; /* interface descriptor remap table */
struct {
dri_bo *bo;
int enabled;
} extended_state;
struct {
dri_bo *bo;
} vfe_state;
struct {
dri_bo *bo;
} curbe;
struct {
unsigned int vfe_start;
unsigned int cs_start;
unsigned int num_vfe_entries;
unsigned int num_cs_entries;
unsigned int size_vfe_entry;
unsigned int size_cs_entry;
} urb;
void (*states_setup)(VADriverContextP ctx, struct decode_state *decode_state);
void (*media_objects)(VADriverContextP ctx, struct decode_state *decode_state);
};
Bool i965_media_init(VADriverContextP ctx);
Bool i965_media_terminate(VADriverContextP ctx);
void i965_media_decode_picture(VADriverContextP ctx,
VAProfile profile,
struct decode_state *decode_state);
#endif /* _I965_MEDIA_H_ */
This diff is collapsed.
/*
* Copyright © 2009 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Xiang Haihao <haihao.xiang@intel.com>
* Zou Nan hai <nanhai.zou@intel.com>
*
*/
#ifndef _I965_MEDIA_MPEG2_H_
#define _I965_MEDIA_MPEG2_H_
#include <xf86drm.h>
#include <drm.h>
#include <i915_drm.h>
#include <intel_bufmgr.h>
#include "i965_structs.h"
struct decode_state;
Bool i965_media_mpeg2_init(VADriverContextP ctx);
Bool i965_media_mpeg2_ternimate(VADriverContextP ctx);
void i965_media_mpeg2_decode_init(VADriverContextP ctx);
#endif /* _I965_MEDIA_MPEG2_H_ */
This diff is collapsed.
/*
* Copyright © 2006 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Xiang Haihao <haihao.xiang@intel.com>
*
*/
#ifndef _I965_RENDER_H_
#define _I965_RENDER_H_
#define MAX_RENDER_SURFACES 16
#define MAX_SAMPLERS 16
struct i965_render_state
{
struct {
dri_bo *vertex_buffer;
} vb;
struct {
dri_bo *state;
} vs;
struct {
dri_bo *state;
dri_bo *prog;
} sf;
struct {
int sampler_count;
dri_bo *sampler;
dri_bo *surface[MAX_RENDER_SURFACES];
dri_bo *binding_table;
dri_bo *state;
dri_bo *prog;
} wm;
struct {
dri_bo *state;
dri_bo *viewport;
} cc;
struct intel_region *draw_region;
};
Bool i965_render_init(VADriverContextP ctx);
Bool i965_render_terminate(VADriverContextP ctx);
void i965_render_put_surface(VADriverContextP ctx,
VASurfaceID surface,
short srcx,
short srcy,
unsigned short srcw,
unsigned short srch,
short destx,
short desty,
unsigned short destw,
unsigned short desth);
void
i965_render_put_subpic(VADriverContextP ctx,
VASurfaceID surface,
short srcx,
short srcy,
unsigned short srcw,
unsigned short srch,
short destx,
short desty,
unsigned short destw,
unsigned short desth);
#endif /* _I965_RENDER_H_ */
This diff is collapsed.
/**************************************************************************
*
* Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include <string.h>
#include <assert.h>
#include "va_backend.h"
#include "intel_batchbuffer.h"
static void
intel_batchbuffer_reset(struct intel_batchbuffer *batch)
{
struct intel_driver_data *intel = batch->intel;
if (batch->buffer != NULL) {
dri_bo_unreference(batch->buffer);
batch->buffer = NULL;
}
batch->buffer = dri_bo_alloc(intel->bufmgr, "batch buffer",
BATCH_SIZE, 0x1000);
assert(batch->buffer);
dri_bo_map(batch->buffer, 1);
batch->map = batch->buffer->virtual;
batch->size = BATCH_SIZE;
batch->ptr = batch->map;
batch->atomic = 0;
}
Bool
intel_batchbuffer_init(struct intel_driver_data *intel)
{
intel->batch = calloc(1, sizeof(*(intel->batch)));
assert(intel->batch);
intel->batch->intel = intel;
intel_batchbuffer_reset(intel->batch);
return True;
}
Bool
intel_batchbuffer_terminate(struct intel_driver_data *intel)
{
if (intel->batch) {
if (intel->batch->map) {
dri_bo_unmap(intel->batch->buffer);
intel->batch->map = NULL;
}
dri_bo_unreference(intel->batch->buffer);
free(intel->batch);
intel->batch = NULL;
}
return True;
}
Bool
intel_batchbuffer_flush(VADriverContextP ctx)
{
struct intel_driver_data *intel = intel_driver_data(ctx);
struct intel_batchbuffer *batch = intel->batch;
unsigned int used = batch->ptr - batch->map;
int is_locked = intel->locked;
if (used == 0) {
return True;
}
if ((used & 4) == 0) {
*(unsigned int*)batch->ptr = 0;
batch->ptr += 4;
}
*(unsigned int*)batch->ptr = MI_BATCH_BUFFER_END;
batch->ptr += 4;
dri_bo_unmap(batch->buffer);
used = batch->ptr - batch->map;
if (!is_locked)
intel_lock_hardware(ctx);
dri_bo_exec(batch->buffer, used, 0, 0, 0);
if (!is_locked)
intel_unlock_hardware(ctx);
intel_batchbuffer_reset(intel->batch);
return True;
}
static unsigned int
intel_batchbuffer_space(struct intel_batchbuffer *batch)
{
return (batch->size - BATCH_RESERVED) - (batch->ptr - batch->map);
}
void
intel_batchbuffer_emit_dword(VADriverContextP ctx, unsigned int x)
{
struct intel_driver_data *intel = intel_driver_data(ctx);
struct intel_batchbuffer *batch = intel->batch;
assert(intel_batchbuffer_space(batch) >= 4);
*(unsigned int*)batch->ptr = x;
batch->ptr += 4;
}
void
intel_batchbuffer_emit_reloc(VADriverContextP ctx, dri_bo *bo,
uint32_t read_domains, uint32_t write_domains,
uint32_t delta)
{
struct intel_driver_data *intel = intel_driver_data(ctx);
struct intel_batchbuffer *batch = intel->batch;
assert(batch->ptr - batch->map < batch->size);
dri_bo_emit_reloc(batch->buffer, read_domains, write_domains,
delta, batch->ptr - batch->map, bo);
intel_batchbuffer_emit_dword(ctx, bo->offset + delta);
}
void
intel_batchbuffer_require_space(VADriverContextP ctx, unsigned int size)
{
struct intel_driver_data *intel = intel_driver_data(ctx);
struct intel_batchbuffer *batch = intel->batch;
assert(size < batch->size - 8);
if (intel_batchbuffer_space(batch) < size) {
intel_batchbuffer_flush(ctx);
}
}
void
intel_batchbuffer_data(VADriverContextP ctx, void *data, unsigned int size)
{
struct intel_driver_data *intel = intel_driver_data(ctx);
struct intel_batchbuffer *batch = intel->batch;
assert((size & 3) == 0);
intel_batchbuffer_require_space(ctx, size);
assert(batch->ptr);
memcpy(batch->ptr, data, size);
batch->ptr += size;
}
void
intel_batchbuffer_emit_mi_flush(VADriverContextP ctx)
{
intel_batchbuffer_require_space(ctx, 4);
intel_batchbuffer_emit_dword(ctx, MI_FLUSH | STATE_INSTRUCTION_CACHE_INVALIDATE);
}
void
intel_batchbuffer_start_atomic(VADriverContextP ctx, unsigned int size)
{
struct intel_driver_data *intel = intel_driver_data(ctx);
struct intel_batchbuffer *batch = intel->batch;
assert(!batch->atomic);
intel_batchbuffer_require_space(ctx, size);
batch->atomic = 1;
}
void
intel_batchbuffer_end_atomic(VADriverContextP ctx)
{
struct intel_driver_data *intel = intel_driver_data(ctx);
struct intel_batchbuffer *batch = intel->batch;
assert(batch->atomic);
batch->atomic = 0;
}
#ifndef _INTEL_BATCHBUFFER_H_
#define _INTEL_BATCHBUFFER_H_
#include <xf86drm.h>
#include <drm.h>
#include <i915_drm.h>
#include <intel_bufmgr.h>
#include "intel_driver.h"
struct intel_batchbuffer
{
struct intel_driver_data *intel;
dri_bo *buffer;
unsigned int size;
unsigned char *map;
unsigned char *ptr;
int atomic;
};
Bool intel_batchbuffer_init(struct intel_driver_data *intel);
Bool intel_batchbuffer_terminate(struct intel_driver_data *intel);
void intel_batchbuffer_emit_dword(VADriverContextP ctx, unsigned int x);
void intel_batchbuffer_emit_reloc(VADriverContextP ctx, dri_bo *bo,
uint32_t read_domains, uint32_t write_domains,
uint32_t delta);
void intel_batchbuffer_require_space(VADriverContextP ctx, unsigned int size);
void intel_batchbuffer_data(VADriverContextP ctx, void *data, unsigned int size);
void intel_batchbuffer_emit_mi_flush(VADriverContextP ctx);
void intel_batchbuffer_start_atomic(VADriverContextP ctx, unsigned int size);
void intel_batchbuffer_end_atomic(VADriverContextP ctx);
Bool intel_batchbuffer_flush(VADriverContextP ctx);
#define BEGIN_BATCH(ctx, n) do { \
intel_batchbuffer_require_space(ctx, (n) * 4); \
} while (0)
#define OUT_BATCH(ctx, d) do { \
intel_batchbuffer_emit_dword(ctx, d); \
} while (0)
#define OUT_RELOC(ctx, bo, read_domains, write_domain, delta) do { \
assert((delta) >= 0); \
intel_batchbuffer_emit_reloc(ctx, bo, \
read_domains, write_domain, delta); \
} while (0)
#define ADVANCE_BATCH(ctx) do { \
} while (0)
#endif /* _INTEL_BATCHBUFFER_H_ */
This diff is collapsed.
This diff is collapsed.
/*
* Copyright © 2009 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Xiang Haihao <haihao.xiang@intel.com>
* Zou Nan hai <nanhai.zou@intel.com>
*
*/
#include <assert.h>
#include "intel_driver.h"
Bool
intel_memman_init(struct intel_driver_data *intel)
{
intel->bufmgr = intel_bufmgr_gem_init(intel->fd, BATCH_SIZE);
assert(intel->bufmgr);
intel_bufmgr_gem_enable_reuse(intel->bufmgr);
return True;
}
Bool
intel_memman_terminate(struct intel_driver_data *intel)
{
return True;
}
#ifndef _INTEL_MEMMAN_H_
#define _INTEL_MEMMAN_H_
Bool intel_memman_init(struct intel_driver_data *intel);
Bool intel_memman_terminate(struct intel_driver_data *intel);
#endif /* _INTEL_MEMMAN_H_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment