Example #1
0
/**
 * Free the resources for an Encoder.
 *
 * Frees the FPGA resources associated with an Encoder.
 */
Encoder::~Encoder() {
  if (!m_counter) {
    int32_t status = 0;
    freeEncoder(m_encoder, &status);
    wpi_setErrorWithContext(status, getHALErrorMessage(status));
  }
}
Example #2
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_EncoderJNI
 * Method:    freeEncoder
 * Signature: (J)V
 */
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_freeEncoder
  (JNIEnv * env, jclass, jlong id)
{
	ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI freeEncoder";
	ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << (void*)id;
	int32_t status = 0;
	freeEncoder((void*)id, &status);
	ENCODERJNI_LOG(logDEBUG) << "Status = " << status;
	CheckStatus(env, status);
}
Example #3
0
/*
 * Class:     edu_wpi_first_wpilibj_hal_EncoderJNI
 * Method:    freeEncoder
 * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V
 */
JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_EncoderJNI_freeEncoder
(JNIEnv * env, jclass, jobject id, jobject status)
{
    ENCODERJNI_LOG(logDEBUG) << "Calling ENCODERJNI freeEncoder";
    void ** javaId = (void**)env->GetDirectBufferAddress(id);
    ENCODERJNI_LOG(logDEBUG) << "Encoder Ptr = " << *javaId;
    jint * statusPtr = (jint*)env->GetDirectBufferAddress(status);
    ENCODERJNI_LOG(logDEBUG) << "Status Ptr = " << statusPtr;
    freeEncoder(*javaId, statusPtr);
    ENCODERJNI_LOG(logDEBUG) << "Status = " << *statusPtr;
}
Example #4
0
/**
 * Free the resources for an Encoder.
 * Frees the FPGA resources associated with an Encoder.
 */
Encoder::~Encoder()
{
	if (m_allocatedASource) delete m_aSource;
	if (m_allocatedBSource) delete m_bSource;
	if (m_counter)
	{
		delete m_counter;
	}
	else
	{
	  	int32_t status = 0;
		freeEncoder(m_encoder, &status);
		wpi_setErrorWithContext(status, getHALErrorMessage(status));
	}
}
uint32_t IntelHWComposerDrm::getCrtcId(int disp)
{
    if (mDrmFd < 0) {
        ALOGE("%s: invalid drm FD\n", __func__);
        return 0;
    }

    drmModeEncoderPtr encoder = NULL;
    drmModeResPtr resources = NULL;
    drmModeCrtcPtr crtc = NULL;
    uint32_t crtc_id = 0;
    int i = 0;

    if ((encoder = getEncoder(disp)) == NULL)
        return 0;

    crtc_id = encoder->crtc_id;
    freeEncoder(encoder);

    if (crtc_id == 0) {
        /* Query an available crtc to use */
        if ((resources = drmModeGetResources(mDrmFd)) == NULL)
            return 0;

        if (!resources->crtcs)
            return 0;

        for (i = 0; i < resources->count_crtcs; i++) {
            crtc = drmModeGetCrtc(mDrmFd, resources->crtcs[i]);
            if (!crtc) {
                ALOGE("%s: Failed to get crtc %d, error is %s",
                        __func__, resources->crtcs[i], strerror(errno));
                continue;
            }
            if (crtc->buffer_id == 0) {
                crtc_id = crtc->crtc_id;
                drmModeFreeCrtc(crtc);
                break;
            }
            drmModeFreeCrtc(crtc);
        }
    }

    return crtc_id;
}