/**
 *
 * @param device - to be created
 * @param driver - driver to use the device
 * @return - status of creation
 */
static gctBOOL SetupDevice
(
        OUT Viv2DDevicePtr * device,
        IN Viv2DDriverPtr driver
        ) {
    TRACE_ENTER();
    gceSTATUS status = gcvSTATUS_OK;
    Viv2DDevicePtr pDeviceHandle;
    gctPOINTER mHandle = gcvNULL;
    /*assertions*/
    gcmASSERT(driver != gcvNULL);
    gcmASSERT(*device == gcvNULL);
    /*Allocation*/
    status = gcoOS_Allocate(gcvNULL, sizeof (Viv2DDevice), &mHandle);
    if (status < 0) {
        TRACE_ERROR("Unable to allocate driver, status = %d\n", status);
        TRACE_EXIT(gcvFALSE);
    }
    pDeviceHandle = (Viv2DDevicePtr) mHandle;
    /*Query*/
    status = gcoHAL_QueryChipIdentity(driver->mHal,
            &pDeviceHandle->mChipModel,
            &pDeviceHandle->mChipRevision,
            &pDeviceHandle->mChipFeatures,
            &pDeviceHandle->mChipMinorFeatures);

    if (status != gcvSTATUS_OK) {
        TRACE_ERROR("Unable to query chip Info, status = %d\n", status);
        TRACE_EXIT(gcvFALSE);
    }
    *device = pDeviceHandle;
    TRACE_EXIT(gcvTRUE);
}
Example #2
0
VEGLThreadData
veglGetThreadData(
    void
    )
{
    gcsTLS_PTR tls = gcvNULL;
    gceSTATUS status;
#if gcdENABLE_VG
    gctINT32 i;
#endif
    gcmHEADER();

    gcmONERROR(gcoOS_GetTLS(&tls));

    if (tls->context == gcvNULL)
    {
        gctPOINTER pointer = gcvNULL;
        VEGLThreadData thread;

        gcmONERROR(gcoOS_Allocate(
            gcvNULL, gcmSIZEOF(struct eglThreadData), &pointer
            ));

        gcmONERROR(gcoOS_ZeroMemory(
            pointer, gcmSIZEOF(struct eglThreadData)
            ));

        /* Initialize TLS record. */
        tls->context    = pointer;
        tls->destructor = _DestroyThreadData;

        /* Cast the pointer. */
        thread = (VEGLThreadData) pointer;

        /* Initialize the thread data. */
        thread->error             = EGL_SUCCESS;
        thread->api               = EGL_OPENGL_ES_API;
        thread->lastClient        = 1;
		thread->worker = gcvNULL;

        tls->currentType           = gcvHARDWARE_3D;
#if veglUSE_HAL_DUMP
        /* Get the gcoDUMP object. */
        gcmONERROR(gcoHAL_GetDump(thread->hal, &thread->dump));
#endif

#if gcdENABLE_VG
        gcmONERROR(gcoHAL_QueryChipCount(gcvNULL, &thread->chipCount));

        for (i = 0; i < thread->chipCount; i++)
        {
            gcmONERROR(gcoHAL_QueryChipLimits(gcvNULL, i, &thread->chipLimits[i]));
        }

        for (i = 0; i < thread->chipCount; i++)
        {
            thread->maxWidth =
                gcmMAX(thread->maxWidth, (gctINT32)thread->chipLimits[i].maxWidth);

            thread->maxHeight =
                gcmMAX(thread->maxHeight, (gctINT32)thread->chipLimits[i].maxHeight);

            thread->maxSamples =
                gcmMAX(thread->maxSamples, (gctINT32)thread->chipLimits[i].maxSamples);
        }

        for (i = 0; i < thread->chipCount; i++)
        {
            /* Query VAA support. */
            if (gcoHAL_QueryChipFeature(gcvNULL, i, gcvFEATURE_VAA))
            {
                thread->vaa = gcvTRUE;
                break;
            }
        }

        for (i = 0; i < thread->chipCount; i++)
        {
            if (gcoHAL_QueryChipFeature(gcvNULL, i, gcvFEATURE_PIPE_VG))
            {
                thread->openVGpipe = _IsHWVGDriverAvailable(thread);
                break;
            }
        }
#else
        /* Query the hardware identity. */
        gcmONERROR(gcoHAL_QueryChipIdentity(
            gcvNULL,
            &thread->chipModel,
            gcvNULL, gcvNULL, gcvNULL
            ));

        /* Query the hardware capabilities. */
        gcmONERROR(gcoHAL_QueryTargetCaps(
            gcvNULL,
            (gctUINT32_PTR) &thread->maxWidth,
            (gctUINT32_PTR) &thread->maxHeight,
            gcvNULL,
            (gctUINT32_PTR) &thread->maxSamples
            ));

        /* Query VAA support. */
        thread->vaa
            =  gcoHAL_IsFeatureAvailable(gcvNULL, gcvFEATURE_VAA)
            == gcvSTATUS_TRUE;

        /* Query OpenVG pipe support. */
        thread->openVGpipe
            =  gcoHAL_IsFeatureAvailable(gcvNULL, gcvFEATURE_PIPE_VG)
            == gcvSTATUS_TRUE;
#endif

        gcmTRACE_ZONE(
            gcvLEVEL_VERBOSE, gcdZONE_EGL_API,
            "%s(%d): maxWidth=%d maxHeight=%d maxSamples=%d vaa=%d openVG=%d",
            __FUNCTION__, __LINE__,
            thread->maxWidth, thread->maxHeight, thread->maxSamples,
            thread->vaa, thread->openVGpipe
            );
    }