summaryrefslogtreecommitdiff
path: root/src/i965_hwmc.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2009-10-06 16:30:08 -0700
committerEric Anholt <eric@anholt.net>2009-10-06 17:10:31 -0700
commit8ae0e44e42db645abe6d385f561260d2ae4a1960 (patch)
tree2002c65e2d302a32ec5d0b19a8708c3c7264b7c6 /src/i965_hwmc.c
parentb9b159c49854d8d9d2207946bb583537bb0d48d6 (diff)
Move to kernel coding style.
We've talked about doing this since the start of the project, putting it off until "some convenient time". Just after removing a third of the driver seems like a convenient time, when backporting's probably not happening much anyway.
Diffstat (limited to 'src/i965_hwmc.c')
-rw-r--r--src/i965_hwmc.c310
1 files changed, 154 insertions, 156 deletions
diff --git a/src/i965_hwmc.c b/src/i965_hwmc.c
index 7f00ba63..3c10f4e8 100644
--- a/src/i965_hwmc.c
+++ b/src/i965_hwmc.c
@@ -50,97 +50,98 @@
static PutImageFuncPtr XvPutImage;
-
-static int create_context(ScrnInfoPtr pScrn,
- XvMCContextPtr context, int *num_privates, CARD32 **private)
+static int create_context(ScrnInfoPtr pScrn,
+ XvMCContextPtr context, int *num_privates,
+ CARD32 ** private)
{
- struct i965_xvmc_context *private_context, *context_dup;
- I830Ptr I830 = I830PTR(pScrn);
-
- unsigned int blocknum =
- (((context->width + 15)/16)*((context->height+15)/16));
- unsigned int blocksize = 6*blocknum*64*sizeof(short);
- blocksize = (blocksize + 4095)&(~4095);
- if ((private_context = Xcalloc(sizeof(*private_context))) == NULL) {
- ErrorF("XVMC Can not allocate private context\n");
- return BadAlloc;
- }
-
- if ((context_dup = Xcalloc(sizeof(*private_context))) == NULL) {
- ErrorF("XVMC Can not allocate private context\n");
- return BadAlloc;
- }
-
- private_context->is_g4x = IS_G4X(I830);
- private_context->is_965_q = IS_965_Q(I830);
- private_context->is_igdng = IS_IGDNG(I830);
- private_context->comm.kernel_exec_fencing = 1;
- private_context->comm.type = xvmc_driver->flag;
-
- *num_privates = sizeof(*private_context)/sizeof(CARD32);
- *private = (CARD32 *)private_context;
- memcpy(context_dup, private_context, sizeof(*private_context));
- context->driver_priv = context_dup;
-
- return Success;
+ struct i965_xvmc_context *private_context, *context_dup;
+ I830Ptr I830 = I830PTR(pScrn);
+
+ unsigned int blocknum =
+ (((context->width + 15) / 16) * ((context->height + 15) / 16));
+ unsigned int blocksize = 6 * blocknum * 64 * sizeof(short);
+ blocksize = (blocksize + 4095) & (~4095);
+ if ((private_context = Xcalloc(sizeof(*private_context))) == NULL) {
+ ErrorF("XVMC Can not allocate private context\n");
+ return BadAlloc;
+ }
+
+ if ((context_dup = Xcalloc(sizeof(*private_context))) == NULL) {
+ ErrorF("XVMC Can not allocate private context\n");
+ return BadAlloc;
+ }
+
+ private_context->is_g4x = IS_G4X(I830);
+ private_context->is_965_q = IS_965_Q(I830);
+ private_context->is_igdng = IS_IGDNG(I830);
+ private_context->comm.kernel_exec_fencing = 1;
+ private_context->comm.type = xvmc_driver->flag;
+
+ *num_privates = sizeof(*private_context) / sizeof(CARD32);
+ *private = (CARD32 *) private_context;
+ memcpy(context_dup, private_context, sizeof(*private_context));
+ context->driver_priv = context_dup;
+
+ return Success;
}
static void destroy_context(ScrnInfoPtr pScrn, XvMCContextPtr context)
{
- struct i965_xvmc_context *private_context;
- private_context = context->driver_priv;
- Xfree(private_context);
+ struct i965_xvmc_context *private_context;
+ private_context = context->driver_priv;
+ Xfree(private_context);
}
static int create_surface(ScrnInfoPtr pScrn, XvMCSurfacePtr surface,
- int *num_priv, CARD32 **priv)
+ int *num_priv, CARD32 ** priv)
{
XvMCContextPtr ctx = surface->context;
struct i965_xvmc_surface *priv_surface, *surface_dup;
struct i965_xvmc_context *priv_ctx = ctx->driver_priv;
int i;
- for (i = 0 ; i < I965_MAX_SURFACES; i++) {
- if (priv_ctx->surfaces[i] == NULL) {
- priv_surface = Xcalloc(sizeof(*priv_surface));
- if (priv_surface == NULL)
- return BadAlloc;
- surface_dup = Xcalloc(sizeof(*priv_surface));
- if (surface_dup == NULL)
- return BadAlloc;
-
- priv_surface->no = i;
- priv_surface->handle = priv_surface;
- priv_surface->w = ctx->width;
- priv_surface->h = ctx->height;
- priv_ctx->surfaces[i] = surface->driver_priv
- = priv_surface;
- memcpy(surface_dup, priv_surface, sizeof(*priv_surface));
- *num_priv = sizeof(*priv_surface)/sizeof(CARD32);
- *priv = (CARD32 *)surface_dup;
- break;
- }
+ for (i = 0; i < I965_MAX_SURFACES; i++) {
+ if (priv_ctx->surfaces[i] == NULL) {
+ priv_surface = Xcalloc(sizeof(*priv_surface));
+ if (priv_surface == NULL)
+ return BadAlloc;
+ surface_dup = Xcalloc(sizeof(*priv_surface));
+ if (surface_dup == NULL)
+ return BadAlloc;
+
+ priv_surface->no = i;
+ priv_surface->handle = priv_surface;
+ priv_surface->w = ctx->width;
+ priv_surface->h = ctx->height;
+ priv_ctx->surfaces[i] = surface->driver_priv
+ = priv_surface;
+ memcpy(surface_dup, priv_surface,
+ sizeof(*priv_surface));
+ *num_priv = sizeof(*priv_surface) / sizeof(CARD32);
+ *priv = (CARD32 *) surface_dup;
+ break;
+ }
}
if (i >= I965_MAX_SURFACES) {
- ErrorF("I965 XVMC too many surfaces in one context\n");
- return BadAlloc;
+ ErrorF("I965 XVMC too many surfaces in one context\n");
+ return BadAlloc;
}
-
+
return Success;
}
static void destory_surface(ScrnInfoPtr pScrn, XvMCSurfacePtr surface)
{
XvMCContextPtr ctx = surface->context;
- struct i965_xvmc_surface *priv_surface = surface->driver_priv;
+ struct i965_xvmc_surface *priv_surface = surface->driver_priv;
struct i965_xvmc_context *priv_ctx = ctx->driver_priv;
priv_ctx->surfaces[priv_surface->no] = NULL;
Xfree(priv_surface);
}
static int create_subpicture(ScrnInfoPtr pScrn, XvMCSubpicturePtr subpicture,
- int *num_priv, CARD32 **priv)
+ int *num_priv, CARD32 ** priv)
{
return Success;
}
@@ -150,32 +151,33 @@ static void destroy_subpicture(ScrnInfoPtr pScrn, XvMCSubpicturePtr subpicture)
}
static int put_image(ScrnInfoPtr pScrn,
- short src_x, short src_y,
- short drw_x, short drw_y, short src_w,
- short src_h, short drw_w, short drw_h,
- int id, unsigned char *buf, short width,
- short height, Bool sync, RegionPtr clipBoxes, pointer data,
- DrawablePtr pDraw)
+ short src_x, short src_y,
+ short drw_x, short drw_y, short src_w,
+ short src_h, short drw_w, short drw_h,
+ int id, unsigned char *buf, short width,
+ short height, Bool sync, RegionPtr clipBoxes, pointer data,
+ DrawablePtr pDraw)
{
I830Ptr pI830 = I830PTR(pScrn);
struct intel_xvmc_command *cmd = (struct intel_xvmc_command *)buf;
dri_bo *bo;
if (id == FOURCC_XVMC) {
- bo = intel_bo_gem_create_from_name(pI830->bufmgr, "surface", cmd->handle);
- dri_bo_pin(bo, 0x1000);
- /* XXX: KMS */
+ bo = intel_bo_gem_create_from_name(pI830->bufmgr, "surface",
+ cmd->handle);
+ dri_bo_pin(bo, 0x1000);
+ /* XXX: KMS */
#if 0
- buf = pI830->FbBase + bo->offset;
+ buf = pI830->FbBase + bo->offset;
#endif
}
XvPutImage(pScrn, src_x, src_y, drw_x, drw_y, src_w, src_h,
- drw_w, drw_h, id, buf, width, height, sync, clipBoxes,
- data, pDraw);
+ drw_w, drw_h, id, buf, width, height, sync, clipBoxes,
+ data, pDraw);
if (id == FOURCC_XVMC) {
- dri_bo_unpin(bo);
- dri_bo_unreference(bo);
+ dri_bo_unpin(bo);
+ dri_bo_unreference(bo);
}
return Success;
@@ -183,113 +185,109 @@ static int put_image(ScrnInfoPtr pScrn,
static Bool init(ScrnInfoPtr screen_info, XF86VideoAdaptorPtr adaptor)
{
- XvPutImage = adaptor->PutImage;
- adaptor->PutImage = put_image;
+ XvPutImage = adaptor->PutImage;
+ adaptor->PutImage = put_image;
- return TRUE;
+ return TRUE;
}
static void fini(ScrnInfoPtr screen_info)
{
}
-static XF86MCSurfaceInfoRec yv12_mpeg2_vld_surface =
-{
- FOURCC_YV12,
- XVMC_CHROMA_FORMAT_420,
- 0,
- 1936,
- 1096,
- 1920,
- 1080,
- XVMC_MPEG_2|XVMC_VLD,
- XVMC_INTRA_UNSIGNED,
- NULL
+static XF86MCSurfaceInfoRec yv12_mpeg2_vld_surface = {
+ FOURCC_YV12,
+ XVMC_CHROMA_FORMAT_420,
+ 0,
+ 1936,
+ 1096,
+ 1920,
+ 1080,
+ XVMC_MPEG_2 | XVMC_VLD,
+ XVMC_INTRA_UNSIGNED,
+ NULL
};
-static XF86MCSurfaceInfoRec yv12_mpeg2_surface =
-{
- FOURCC_YV12,
- XVMC_CHROMA_FORMAT_420,
- 0,
- 1936,
- 1096,
- 1920,
- 1080,
- XVMC_MPEG_2|XVMC_MOCOMP,
- /* XVMC_OVERLAID_SURFACE | XVMC_SUBPICTURE_INDEPENDENT_SCALING,*/
- XVMC_INTRA_UNSIGNED,
- /* &yv12_subpicture_list*/
- NULL
+static XF86MCSurfaceInfoRec yv12_mpeg2_surface = {
+ FOURCC_YV12,
+ XVMC_CHROMA_FORMAT_420,
+ 0,
+ 1936,
+ 1096,
+ 1920,
+ 1080,
+ XVMC_MPEG_2 | XVMC_MOCOMP,
+ /* XVMC_OVERLAID_SURFACE | XVMC_SUBPICTURE_INDEPENDENT_SCALING, */
+ XVMC_INTRA_UNSIGNED,
+ /* &yv12_subpicture_list */
+ NULL
};
-static XF86MCSurfaceInfoRec yv12_mpeg1_surface =
-{
- FOURCC_YV12,
- XVMC_CHROMA_FORMAT_420,
- 0,
- 1920,
- 1080,
- 1920,
- 1080,
- XVMC_MPEG_1|XVMC_MOCOMP,
- /*XVMC_OVERLAID_SURFACE | XVMC_SUBPICTURE_INDEPENDENT_SCALING |
- XVMC_INTRA_UNSIGNED,*/
- XVMC_INTRA_UNSIGNED,
-
- /*&yv12_subpicture_list*/
- NULL
+static XF86MCSurfaceInfoRec yv12_mpeg1_surface = {
+ FOURCC_YV12,
+ XVMC_CHROMA_FORMAT_420,
+ 0,
+ 1920,
+ 1080,
+ 1920,
+ 1080,
+ XVMC_MPEG_1 | XVMC_MOCOMP,
+ /*XVMC_OVERLAID_SURFACE | XVMC_SUBPICTURE_INDEPENDENT_SCALING |
+ XVMC_INTRA_UNSIGNED, */
+ XVMC_INTRA_UNSIGNED,
+
+ /*&yv12_subpicture_list */
+ NULL
};
static XF86MCSurfaceInfoPtr surface_info[] = {
- &yv12_mpeg2_surface,
- &yv12_mpeg1_surface
+ &yv12_mpeg2_surface,
+ &yv12_mpeg1_surface
};
static XF86MCSurfaceInfoPtr surface_info_vld[] = {
- &yv12_mpeg2_vld_surface,
- &yv12_mpeg2_surface,
+ &yv12_mpeg2_vld_surface,
+ &yv12_mpeg2_surface,
};
static XF86MCAdaptorRec adaptor_vld = {
- .name = "Intel(R) Textured Video",
- .num_surfaces = sizeof(surface_info_vld)/sizeof(surface_info_vld[0]),
- .surfaces = surface_info_vld,
-
- .CreateContext = create_context,
- .DestroyContext = destroy_context,
- .CreateSurface = create_surface,
- .DestroySurface = destory_surface,
- .CreateSubpicture = create_subpicture,
- .DestroySubpicture = destroy_subpicture
+ .name = "Intel(R) Textured Video",
+ .num_surfaces = sizeof(surface_info_vld) / sizeof(surface_info_vld[0]),
+ .surfaces = surface_info_vld,
+
+ .CreateContext = create_context,
+ .DestroyContext = destroy_context,
+ .CreateSurface = create_surface,
+ .DestroySurface = destory_surface,
+ .CreateSubpicture = create_subpicture,
+ .DestroySubpicture = destroy_subpicture
};
static XF86MCAdaptorRec adaptor = {
- .name = "Intel(R) Textured Video",
- .num_surfaces = sizeof(surface_info)/sizeof(surface_info[0]),
- .surfaces = surface_info,
-
- .CreateContext = create_context,
- .DestroyContext = destroy_context,
- .CreateSurface = create_surface,
- .DestroySurface = destory_surface,
- .CreateSubpicture = create_subpicture,
- .DestroySubpicture = destroy_subpicture
+ .name = "Intel(R) Textured Video",
+ .num_surfaces = sizeof(surface_info) / sizeof(surface_info[0]),
+ .surfaces = surface_info,
+
+ .CreateContext = create_context,
+ .DestroyContext = destroy_context,
+ .CreateSurface = create_surface,
+ .DestroySurface = destory_surface,
+ .CreateSubpicture = create_subpicture,
+ .DestroySubpicture = destroy_subpicture
};
struct intel_xvmc_driver i965_xvmc_driver = {
- .name = "i965_xvmc",
- .adaptor = &adaptor,
- .flag = XVMC_I965_MPEG2_MC,
- .init = init,
- .fini = fini
+ .name = "i965_xvmc",
+ .adaptor = &adaptor,
+ .flag = XVMC_I965_MPEG2_MC,
+ .init = init,
+ .fini = fini
};
-struct intel_xvmc_driver vld_xvmc_driver = {
- .name = "xvmc_vld",
- .adaptor = &adaptor_vld,
- .flag = XVMC_I965_MPEG2_VLD,
- .init = init,
- .fini = fini
+struct intel_xvmc_driver vld_xvmc_driver = {
+ .name = "xvmc_vld",
+ .adaptor = &adaptor_vld,
+ .flag = XVMC_I965_MPEG2_VLD,
+ .init = init,
+ .fini = fini
};
-