bool MdpCtrl::set() {
    int mdpVersion = MDPVersion::getInstance().getMDPVersion();
    //deferred calcs, so APIs could be called in any order.
    doTransform();
    utils::Whf whf = getSrcWhf();
    if(utils::isYuv(whf.format)) {
        utils::normalizeCrop(mOVInfo.src_rect.x, mOVInfo.src_rect.w);
        utils::normalizeCrop(mOVInfo.src_rect.y, mOVInfo.src_rect.h);
        if(mdpVersion < MDSS_V5) {
            utils::even_floor(mOVInfo.dst_rect.w);
            utils::even_floor(mOVInfo.dst_rect.h);
        } else if (mOVInfo.flags & MDP_DEINTERLACE) {
            // For interlaced, crop.h should be 4-aligned
            if (!(mOVInfo.flags & MDP_SOURCE_ROTATED_90) &&
                (mOVInfo.src_rect.h % 4))
                mOVInfo.src_rect.h = utils::aligndown(mOVInfo.src_rect.h, 4);
            // For interlaced, width must be multiple of 4 when rotated 90deg.
            else if ((mOVInfo.flags & MDP_SOURCE_ROTATED_90) &&
                (mOVInfo.src_rect.w % 4))
                mOVInfo.src_rect.w = utils::aligndown(mOVInfo.src_rect.w, 4);
        }
    } else {
        if (mdpVersion >= MDSS_V5) {
            // Check for 1-pixel down-scaling
            if (mOVInfo.src_rect.w - mOVInfo.dst_rect.w == 1)
                mOVInfo.src_rect.w -= 1;
            if (mOVInfo.src_rect.h - mOVInfo.dst_rect.h == 1)
                mOVInfo.src_rect.h -= 1;
        }
    }

    doDownscale();
    return true;
}
Example #2
0
bool MdpCtrl::set() {
    //deferred calcs, so APIs could be called in any order.
    doTransform();
    utils::Whf whf = getSrcWhf();
    if(utils::isYuv(whf.format)) {
        normalizeCrop(mOVInfo.src_rect.x, mOVInfo.src_rect.w);
        normalizeCrop(mOVInfo.src_rect.y, mOVInfo.src_rect.h);
        utils::even_floor(mOVInfo.dst_rect.w);
        utils::even_floor(mOVInfo.dst_rect.h);
    }

    if(this->ovChanged()) {
        if(!mdp_wrapper::setOverlay(mFd.getFD(), mOVInfo)) {
            ALOGE("MdpCtrl failed to setOverlay, restoring last known "
                  "good ov info");
            mdp_wrapper::dump("== Bad OVInfo is: ", mOVInfo);
            mdp_wrapper::dump("== Last good known OVInfo is: ", mLkgo);
            this->restore();
            return false;
        }
        this->save();
    }

    return true;
}
void MdpCtrl::doTransform() {
    setRotationFlags();
    utils::Whf whf = getSrcWhf();
    utils::Dim dim = getSrcRectDim();
    utils::preRotateSource(mOrientation, whf, dim);
    setSrcWhf(whf);
    setSrcRectDim(dim);
}
Example #4
0
//Adjust width, height, format if rotator is used.
void MdpCtrl::adjustSrcWhf(const bool& rotUsed) {
    if(rotUsed) {
        utils::Whf whf = getSrcWhf();
        if(whf.format == MDP_Y_CRCB_H2V2_TILE ||
                whf.format == MDP_Y_CBCR_H2V2_TILE) {
            whf.w = utils::alignup(whf.w, 64);
            whf.h = utils::alignup(whf.h, 32);
        }
        //For example: If original format is tiled, rotator outputs non-tiled,
        //so update mdp's src fmt to that.
        whf.format = utils::getRotOutFmt(whf.format);
        setSrcWhf(whf);
    }
}
//Update src format based on rotator's destination format.
void MdpCtrl::updateSrcFormat(const uint32_t& rotDestFmt) {
    utils::Whf whf = getSrcWhf();
    whf.format =  rotDestFmt;
    setSrcWhf(whf);
}
Example #6
0
bool MdpCtrl::setCrop(const utils::Dim& cdim) {
    utils::Dim d(cdim);
    const utils::Whf ovwhf = getSrcWhf();
    int udata = getUserData();
    switch(udata) {
        case MDP_ROT_NOP:
            break; // nothing to do here
        case MDP_ROT_90:
        case MDP_ROT_90 | MDP_FLIP_UD:
        case MDP_ROT_90 | MDP_FLIP_LR:
            {
                if (ovwhf.w < (d.y + d.h)) {
                    ALOGE("MdpCtrl setCrop failed ROT 90 udata=%d",
                            udata);
                    d.dump();
                    this->dump();
                    return false;
                }
                uint32_t tmp = d.x;
                d.x = ovwhf.w - (d.y + d.h);
                d.y = tmp;
                utils::swap(d.w, d.h);
            }break;
        case MDP_ROT_270:
            {
                if (ovwhf.h < (d.x + d.w)) {
                    ALOGE("MdpCtrl setCrop failed ROT 270 udata=%d",
                            udata);
                    d.dump();
                    this->dump();
                    return false;
                }
                uint32_t tmp = d.y;
                d.y = ovwhf.h - (d.x + d.w);
                d.x = tmp;
                utils::swap(d.w, d.h);
            }break;
        case MDP_ROT_180:
            {
                if ((ovwhf.h < (d.y + d.h)) ||
                        (ovwhf.w < ( d.x + d.w))) {
                    ALOGE("MdpCtrl setCrop failed ROT 180 udata=%d",
                            udata);
                    d.dump();
                    this->dump();
                    return false;
                }
                d.x = ovwhf.w - (d.x + d.w);
                d.y = ovwhf.h - (d.y + d.h);
            }break;
        default:
            if(!(udata & (MDP_FLIP_UD | MDP_FLIP_LR))) {
                ALOGE("MdpCtrl setCrop unknown rot %d", udata);
                return false;
            }
    }

    if(getSrcRectDim() == d) {
        return true; // Nothing to do here
    }

    utils::normalizeCrop(d.x, d.w);
    utils::normalizeCrop(d.y, d.h);

    setSrcRectDim(d);

    return true;
}