summaryrefslogtreecommitdiff
path: root/sgx/services4/3rdparty/bufferclass_example/bufferclass_example.c
blob: e39a3728f5d2140975026adea62a2757e3317b6c (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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
/*************************************************************************/ /*!
@Title          bufferclass_example kernel driver
@Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
@License        Dual MIT/GPLv2

The contents of this file are subject to the MIT license as set out below.

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 shall be included in
all copies or substantial portions of the Software.

Alternatively, the contents of this file may be used under the terms of
the GNU General Public License Version 2 ("GPL") in which case the provisions
of GPL are applicable instead of those above.

If you wish to allow use of your version of this file only under the terms of
GPL, and not to allow others to use your version of this file under the terms
of the MIT license, indicate your decision by deleting the provisions above
and replace them with the notice and other provisions required by GPL as set
out in the file called "GPL-COPYING" included in this distribution. If you do
not delete the provisions above, a recipient may use your version of this file
under the terms of either the MIT license or GPL.

This License is also included in this distribution in the file called
"MIT-COPYING".

EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) 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; AND (B) 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.
  
*/ /**************************************************************************/

/**************************************************************************
 The 3rd party driver is a specification of an API to integrate the IMG POWERVR
 Services driver with a 3rd Party 'buffer device'.  It is NOT a specification for
 a 'buffer device' driver, rather a specification to extend the API for a
 pre-existing driver for the 'buffer device' hardware.

 The 3rd party driver interface provides IMG POWERVR client drivers (e.g. PVR2D)
 with an API abstraction of the system's underlying buffer device hardware, 
 allowing the client drivers to indirectly control the buffer device hardware
 and access its associated memory.
 
 Functions of the API include
 - query buffer device surface attributes (width, height, stride, pixel format, 
 CPU physical and virtual address)

 Note: having queried surface attributes the client drivers are able to map the
 buffer device memory to any IMG POWERVR Services device by calling
 PVRSRVMapDeviceClassMemory with the buffer device surface handle.

 This code is intended to be an example of how a pre-existing buffer device
 driver may be extended to support the 3rd Party buffer device interface to 
 POWERVR Services
 - IMG is not providing a buffer device driver implementation.
 **************************************************************************/
#if defined(__linux__)
#include <linux/string.h>
#else
#include <string.h>
#endif

#include "bufferclass_example.h"



#define BUFFERCLASS_DEVICE_NAME "Example Bufferclass Device (SW)"

/* top level 'hook ptr' */
static void *gpvAnchor = NULL;
static PFN_BC_GET_PVRJTABLE pfnGetPVRJTable = IMG_NULL;

/*
	Kernel services is a kernel module and must be loaded first.
	This driver is also a kernel module and must be loaded after the pvr services module.
	This driver should be able to retrieve the
	address of the services PVRGetBufferClassJTable from (the already loaded)
	kernel services module.
*/

/* returns anchor pointer */
BC_EXAMPLE_DEVINFO * GetAnchorPtr(void)
{
	return (BC_EXAMPLE_DEVINFO *)gpvAnchor;
}

/* sets anchor pointer */
static void SetAnchorPtr(BC_EXAMPLE_DEVINFO *psDevInfo)
{
	gpvAnchor = (void *)psDevInfo;
}


/* Open device function, called from services */
static PVRSRV_ERROR OpenBCDevice(IMG_UINT32 ui32DeviceID, IMG_HANDLE *phDevice)
{
	BC_EXAMPLE_DEVINFO *psDevInfo;
	
	/*
		bufferclass_example manages only one BufferClass device
		therefore there is no need to track ID numbers.
	*/
	UNREFERENCED_PARAMETER(ui32DeviceID);

	psDevInfo = GetAnchorPtr();

	/* return handle to the devinfo */
	*phDevice = (IMG_HANDLE)psDevInfo;

	return (PVRSRV_OK);
}


/* Close device function, called from services */
static PVRSRV_ERROR CloseBCDevice(IMG_UINT32 ui32DeviceID, IMG_HANDLE hDevice)
{
	UNREFERENCED_PARAMETER(hDevice);

	return (PVRSRV_OK);
}

/* Passes in the sync data for a buffer, and returns the handle */
/* called from services */
static PVRSRV_ERROR GetBCBuffer(IMG_HANDLE          hDevice,
                                IMG_UINT32          ui32BufferNumber,
                                PVRSRV_SYNC_DATA   *psSyncData,
                                IMG_HANDLE         *phBuffer)
{
	BC_EXAMPLE_DEVINFO	*psDevInfo;

	if(!hDevice || !phBuffer)
	{
		return (PVRSRV_ERROR_INVALID_PARAMS);
	}

	psDevInfo = (BC_EXAMPLE_DEVINFO*)hDevice;

	if( ui32BufferNumber < psDevInfo->sBufferInfo.ui32BufferCount )
	{
		psDevInfo->psSystemBuffer[ui32BufferNumber].psSyncData = psSyncData;
		*phBuffer = (IMG_HANDLE)&psDevInfo->psSystemBuffer[ui32BufferNumber];
	}
	else
	{
		return (PVRSRV_ERROR_INVALID_PARAMS);
	}

	return (PVRSRV_OK);
}


/* get buffer info function, called from services */
static PVRSRV_ERROR GetBCInfo(IMG_HANDLE hDevice, BUFFER_INFO *psBCInfo)
{
	BC_EXAMPLE_DEVINFO	*psDevInfo;

	if(!hDevice || !psBCInfo)
	{
		return (PVRSRV_ERROR_INVALID_PARAMS);
	}

	psDevInfo = (BC_EXAMPLE_DEVINFO*)hDevice;

	*psBCInfo = psDevInfo->sBufferInfo;

	return (PVRSRV_OK);
}


/* get buffer address function, called from services */
static PVRSRV_ERROR GetBCBufferAddr(IMG_HANDLE      hDevice,
                                    IMG_HANDLE      hBuffer,
                                    IMG_SYS_PHYADDR **ppsSysAddr,
                                    IMG_UINT32      *pui32ByteSize,
                                    IMG_VOID        **ppvCpuVAddr,
                                    IMG_HANDLE      *phOSMapInfo,
                                    IMG_BOOL        *pbIsContiguous,
                                    IMG_UINT32      *pui32TilingStride)
{
	BC_EXAMPLE_BUFFER *psBuffer;

	PVR_UNREFERENCED_PARAMETER(pui32TilingStride);

	if(!hDevice || !hBuffer || !ppsSysAddr || !pui32ByteSize)
	{
		return (PVRSRV_ERROR_INVALID_PARAMS);
	}

	psBuffer = (BC_EXAMPLE_BUFFER *) hBuffer;

	*ppvCpuVAddr = psBuffer->sCPUVAddr;

	*phOSMapInfo    = IMG_NULL;
	*pui32ByteSize = (IMG_UINT32)psBuffer->ulSize;

#if defined(BC_DISCONTIG_BUFFERS)
	*ppsSysAddr = psBuffer->psSysAddr;
	*pbIsContiguous = IMG_FALSE;
#else
	*ppsSysAddr = &psBuffer->sPageAlignSysAddr;
	*pbIsContiguous = IMG_TRUE;
#endif

	return (PVRSRV_OK);
}


/* 
 *  Register the device with services module srvkm.
 *  This should only be done once at boot time.
 */
BCE_ERROR BC_Example_Register(void)
{
	BC_EXAMPLE_DEVINFO	*psDevInfo;

	/*
		- connect to services
		- register with services
		- allocate and setup private data structure
	*/


	/*
		in kernel driver, data structures must be anchored to something for subsequent retrieval
		this may be a single global pointer or TLS or something else - up to you
		call API to retrieve this ptr
	*/

	/*
		get the anchor pointer 
	*/
	psDevInfo = GetAnchorPtr();

	if (psDevInfo == NULL)
	{
		/* allocate device info. structure */
		psDevInfo = (BC_EXAMPLE_DEVINFO *)BCAllocKernelMem(sizeof(BC_EXAMPLE_DEVINFO));

		if(!psDevInfo)
		{
			return (BCE_ERROR_OUT_OF_MEMORY);/* failure */
		}

		/* set the top-level anchor */
		SetAnchorPtr((void*)psDevInfo);

		/* set ref count */
		psDevInfo->ulRefCount = 0;

	
		if(BCOpenPVRServices(&psDevInfo->hPVRServices) != BCE_OK)
		{
			return (BCE_ERROR_INIT_FAILURE);/* failure */
		}
		if(BCGetLibFuncAddr (psDevInfo->hPVRServices, "PVRGetBufferClassJTable", &pfnGetPVRJTable) != BCE_OK)
		{
			return (BCE_ERROR_INIT_FAILURE);/* failure */
		}

		/* got the kernel services function table */
		if(!(*pfnGetPVRJTable)(&psDevInfo->sPVRJTable))
		{
			return (BCE_ERROR_INIT_FAILURE);/* failure */
		}

		/*
			Setup the devinfo
		*/

		psDevInfo->ulNumBuffers = 0;

		psDevInfo->psSystemBuffer = BCAllocKernelMem(sizeof(BC_EXAMPLE_BUFFER) * BC_EXAMPLE_NUM_BUFFERS);

		if(!psDevInfo->psSystemBuffer)
		{
			return (BCE_ERROR_OUT_OF_MEMORY);/* failure */
		}

		/* Setup Buffer Info */
		psDevInfo->sBufferInfo.pixelformat        = PVRSRV_PIXEL_FORMAT_UNKNOWN;
		psDevInfo->sBufferInfo.ui32Width          = 0;
		psDevInfo->sBufferInfo.ui32Height         = 0;
		psDevInfo->sBufferInfo.ui32ByteStride     = 0;
		psDevInfo->sBufferInfo.ui32BufferDeviceID = BC_EXAMPLE_DEVICEID;
		psDevInfo->sBufferInfo.ui32Flags          = 0;
		psDevInfo->sBufferInfo.ui32BufferCount    = (IMG_UINT32)psDevInfo->ulNumBuffers;
		
		strncpy(psDevInfo->sBufferInfo.szDeviceName, BUFFERCLASS_DEVICE_NAME, MAX_BUFFER_DEVICE_NAME_SIZE);

		/*
			Bsetup the BC Jtable so SRVKM can call into this driver
		*/
		psDevInfo->sBCJTable.ui32TableSize    = sizeof(PVRSRV_BC_SRV2BUFFER_KMJTABLE);
		psDevInfo->sBCJTable.pfnOpenBCDevice  = OpenBCDevice;
		psDevInfo->sBCJTable.pfnCloseBCDevice = CloseBCDevice;
		psDevInfo->sBCJTable.pfnGetBCBuffer   = GetBCBuffer;
		psDevInfo->sBCJTable.pfnGetBCInfo     = GetBCInfo;
		psDevInfo->sBCJTable.pfnGetBufferAddr = GetBCBufferAddr;


		/* register device with services and retrieve device index */
		/* This example only registers 1 device, but for multiple buffer streams, register more devices */
		if(psDevInfo->sPVRJTable.pfnPVRSRVRegisterBCDevice (&psDevInfo->sBCJTable,
															(IMG_UINT32*)&psDevInfo->ulDeviceID ) != PVRSRV_OK)
		{
			return (BCE_ERROR_DEVICE_REGISTER_FAILED);/* failure */
		}
	}

	/* increment the ref count */
	psDevInfo->ulRefCount++;

	/* return success */
	return (BCE_OK);
}

/* 
 *  Unregister the device with services module srvkm.
 */
BCE_ERROR BC_Example_Unregister(void)
{
	BC_EXAMPLE_DEVINFO *psDevInfo;

	psDevInfo = GetAnchorPtr();

	/* check DevInfo has been setup */
	if (psDevInfo == NULL)
	{
		return (BCE_ERROR_GENERIC);/* failure */
	}
	/* decrement ref count */
	psDevInfo->ulRefCount--;

	if (psDevInfo->ulRefCount == 0)
	{
		/* all references gone - de-init device information */
		PVRSRV_BC_BUFFER2SRV_KMJTABLE	*psJTable = &psDevInfo->sPVRJTable;


		/* Remove the device from kernel services device register */
		if (psJTable->pfnPVRSRVRemoveBCDevice(psDevInfo->ulDeviceID) != PVRSRV_OK)
		{
			return (BCE_ERROR_GENERIC);/* failure */
		}

		if (BCClosePVRServices(psDevInfo->hPVRServices) != BCE_OK)
		{
			psDevInfo->hPVRServices = NULL;
			return (BCE_ERROR_GENERIC);/* failure */
		}

		if (psDevInfo->psSystemBuffer)
		{
			BCFreeKernelMem(psDevInfo->psSystemBuffer);
		}

		/* de-allocate data structure */
		BCFreeKernelMem(psDevInfo);

		/* clear the top-level anchor */
		SetAnchorPtr(NULL);
	}

	/* return success */
	return (BCE_OK);
}


/* 
 * Create shared buffers. 
 */
BCE_ERROR BC_Example_Buffers_Create(void)
{
	BC_EXAMPLE_DEVINFO  *psDevInfo;
	unsigned long        i;
#if !defined(BC_DISCONTIG_BUFFERS)
	IMG_CPU_PHYADDR      sSystemBufferCPUPAddr;
#endif
	PVRSRV_PIXEL_FORMAT  pixelformat    = BC_EXAMPLE_PIXELFORMAT;
	static IMG_UINT32    ui32Width      = BC_EXAMPLE_WIDTH;
	static IMG_UINT32    ui32Height     = BC_EXAMPLE_HEIGHT;
	static IMG_UINT32    ui32ByteStride = BC_EXAMPLE_STRIDE;

	IMG_UINT32 ui32MaxWidth = 320 * 4;

	/*
		get the anchor pointer 
	*/
	psDevInfo = GetAnchorPtr();
	if (psDevInfo == NULL)
	{
		/* 
		 * This device was not correctly registered/created. 
		 */
		return (BCE_ERROR_DEVICE_REGISTER_FAILED);
	}
	if (psDevInfo->ulNumBuffers)
	{
		/* Buffers already allocated */
		return (BCE_ERROR_GENERIC);
	}
		
	/* Setup Buffer Info */
	psDevInfo->sBufferInfo.pixelformat        = BC_EXAMPLE_PIXELFORMAT;
	psDevInfo->sBufferInfo.ui32Width          = ui32Width;
	psDevInfo->sBufferInfo.ui32Height         = ui32Height;
	psDevInfo->sBufferInfo.ui32ByteStride     = ui32ByteStride;
	psDevInfo->sBufferInfo.ui32BufferDeviceID = BC_EXAMPLE_DEVICEID;
	psDevInfo->sBufferInfo.ui32Flags          = PVRSRV_BC_FLAGS_YUVCSC_FULL_RANGE | PVRSRV_BC_FLAGS_YUVCSC_BT601;

	for(i=psDevInfo->ulNumBuffers; i < BC_EXAMPLE_NUM_BUFFERS; i++)
	{
		unsigned long ulSize = (unsigned long)(ui32Height * ui32ByteStride);

		if(psDevInfo->sBufferInfo.pixelformat == PVRSRV_PIXEL_FORMAT_NV12)
		{
			/* Second plane is quarter size, but 2bytes per pixel */
			ulSize += ((ui32ByteStride >> 1) * (ui32Height >> 1) << 1);
		}
		else if(psDevInfo->sBufferInfo.pixelformat == PVRSRV_PIXEL_FORMAT_YV12)
		{
			/* Second plane is quarter size, but 1byte per pixel */
			ulSize += (ui32ByteStride >> 1) * (ui32Height >> 1);
			
			/* third plane is quarter size, but 1byte per pixel */
			ulSize += (ui32ByteStride >> 1) * (ui32Height >> 1);
		}

#if defined(BC_DISCONTIG_BUFFERS)
		if (BCAllocDiscontigMemory(ulSize,
								   &psDevInfo->psSystemBuffer[i].hMemHandle,
								   &psDevInfo->psSystemBuffer[i].sCPUVAddr,
								   &psDevInfo->psSystemBuffer[i].psSysAddr) != BCE_OK)
		{
			break;
		}
#else
		/* Setup system buffer */
		if (BCAllocContigMemory(ulSize,
		                        &psDevInfo->psSystemBuffer[i].hMemHandle,
		                        &psDevInfo->psSystemBuffer[i].sCPUVAddr,
		                        &sSystemBufferCPUPAddr) != BCE_OK)
		{
			break;
		}
		psDevInfo->psSystemBuffer[i].sSysAddr = CpuPAddrToSysPAddrBC(sSystemBufferCPUPAddr);
		psDevInfo->psSystemBuffer[i].sPageAlignSysAddr.uiAddr = (psDevInfo->psSystemBuffer[i].sSysAddr.uiAddr & 0xFFFFF000);
#endif

		psDevInfo->ulNumBuffers++;

		psDevInfo->psSystemBuffer[i].ulSize = ulSize;
		psDevInfo->psSystemBuffer[i].psSyncData = NULL;
	}

	psDevInfo->sBufferInfo.ui32BufferCount = (IMG_UINT32)psDevInfo->ulNumBuffers;

	/*
		Bsetup the BC Jtable so SRVKM can call into this driver
	*/
	psDevInfo->sBCJTable.ui32TableSize    = sizeof(PVRSRV_BC_SRV2BUFFER_KMJTABLE);
	psDevInfo->sBCJTable.pfnOpenBCDevice  = OpenBCDevice;
	psDevInfo->sBCJTable.pfnCloseBCDevice = CloseBCDevice;
	psDevInfo->sBCJTable.pfnGetBCBuffer   = GetBCBuffer;
	psDevInfo->sBCJTable.pfnGetBCInfo     = GetBCInfo;
	psDevInfo->sBCJTable.pfnGetBufferAddr = GetBCBufferAddr;
	


	/* Update buffer's parameters for reconfiguration next time */
	if (ui32Width < ui32MaxWidth)
	{
		switch(pixelformat)
		{
		    case PVRSRV_PIXEL_FORMAT_NV12:
		    case PVRSRV_PIXEL_FORMAT_YV12:
			{
			    ui32Width += 320;
				ui32Height += 160;
				ui32ByteStride = ui32Width;
				break;
			}
		    case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_VYUY:
		    case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_UYVY:
		    case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_YUYV:
		    case PVRSRV_PIXEL_FORMAT_FOURCC_ORG_YVYU:
			{
			    ui32Width += 320;
				ui32Height += 160;
				ui32ByteStride = ui32Width*2;
				break;
			}
		    case PVRSRV_PIXEL_FORMAT_RGB565:
			{
			    ui32Width += 320;
				ui32Height += 160;
				ui32ByteStride = ui32Width*2;
				break;
			}
		    default:
			{
				return (BCE_ERROR_INVALID_PARAMS);
			}
		}
	}
	else
	{
		ui32Width      = BC_EXAMPLE_WIDTH;
		ui32Height     = BC_EXAMPLE_HEIGHT;
		ui32ByteStride = BC_EXAMPLE_STRIDE;
	}

	/* return success */
	return (BCE_OK);
}


/*
 * Destroy shared buffers.
 */
BCE_ERROR BC_Example_Buffers_Destroy(void)
{
	BC_EXAMPLE_DEVINFO *psDevInfo;
	unsigned long       i;

	psDevInfo = GetAnchorPtr();

	/* check DevInfo has been setup */
	if (psDevInfo == NULL)
	{
		/* 
		   This device was not correctly registered/created. 
		 */
		return (BCE_ERROR_DEVICE_REGISTER_FAILED);
	}

	/* 
	   Free all allocated surfaces 
	*/
	for(i = 0; i < psDevInfo->ulNumBuffers; i++)
	{
#if defined(BC_DISCONTIG_BUFFERS)
		BCFreeDiscontigMemory(psDevInfo->psSystemBuffer[i].ulSize,
			 psDevInfo->psSystemBuffer[i].hMemHandle,
			 psDevInfo->psSystemBuffer[i].sCPUVAddr,
			 psDevInfo->psSystemBuffer[i].psSysAddr);
#else
		BCFreeContigMemory(psDevInfo->psSystemBuffer[i].ulSize,
				psDevInfo->psSystemBuffer[i].hMemHandle,
				psDevInfo->psSystemBuffer[i].sCPUVAddr,
				SysPAddrToCpuPAddrBC(psDevInfo->psSystemBuffer[i].sSysAddr));
#endif
	}
	psDevInfo->ulNumBuffers = 0;

	/* Reset buffer info */
	psDevInfo->sBufferInfo.pixelformat        = PVRSRV_PIXEL_FORMAT_UNKNOWN;
	psDevInfo->sBufferInfo.ui32Width          = 0;
	psDevInfo->sBufferInfo.ui32Height         = 0;
	psDevInfo->sBufferInfo.ui32ByteStride     = 0;
	psDevInfo->sBufferInfo.ui32BufferDeviceID = BC_EXAMPLE_DEVICEID;
	psDevInfo->sBufferInfo.ui32Flags          = 0;
	psDevInfo->sBufferInfo.ui32BufferCount    = (IMG_UINT32)psDevInfo->ulNumBuffers;

	/* return success */
	return (BCE_OK);
}


/* 
 * This function does both registration and buffer allocation at
 * boot time.
 */
BCE_ERROR  BC_Example_Init(void)
{
	BCE_ERROR eError;

	eError = BC_Example_Register();
	if (eError != BCE_OK)
	{
		return eError;
	}

	eError = BC_Example_Buffers_Create();
	if (eError != BCE_OK)
	{
		return eError;
	}

	return (BCE_OK);
}

/* 
 *	Destroy buffers and unregister device.
 */
BCE_ERROR BC_Example_Deinit(void)
{
	BCE_ERROR eError;

	eError = BC_Example_Buffers_Destroy();
	if (eError != BCE_OK)
	{
		return eError;
	}

	eError = BC_Example_Unregister();
	if (eError != BCE_OK)
	{
		return eError;
	}

	return (BCE_OK);
}

/******************************************************************************
 End of file (bufferclass_example.c)
******************************************************************************/