コード例 #1
0
s32 stbuf_init(struct stream_buf_s *buf)
{
    s32 r;
    u32 dummy;
    u32 phy_addr;

    if (buf->flag & BUF_FLAG_IOMEM) {
        phy_addr = buf->buf_start;
    } else {
        r = _stbuf_alloc(buf);
        if (r < 0) {
            return r;
        }
        phy_addr = virt_to_phys((void *)buf->buf_start);
    }

    init_waitqueue_head(&buf->wq);

    _WRITE_ST_REG(CONTROL, 0);

    if (buf->type == BUF_TYPE_VIDEO) {
        /* reset VLD before setting all pointers */
        WRITE_MPEG_REG(RESET0_REGISTER, RESET_VLD);
        dummy = READ_MPEG_REG(RESET0_REGISTER);
        WRITE_MPEG_REG(POWER_CTL_VLD, 1 << 4);
    } else if (buf->type == BUF_TYPE_AUDIO) {
        WRITE_MPEG_REG(AIU_AIFIFO_GBIT, 0x80);
    }

    if (buf->type == BUF_TYPE_SUBTITLE) {
        WRITE_MPEG_REG(PARSER_SUB_RP, phy_addr);
        WRITE_MPEG_REG(PARSER_SUB_START_PTR, phy_addr);
        WRITE_MPEG_REG(PARSER_SUB_END_PTR, phy_addr + buf->buf_size - 8);

        return 0;
    }

    _WRITE_ST_REG(START_PTR, phy_addr);
    _WRITE_ST_REG(CURR_PTR, phy_addr);
    _WRITE_ST_REG(END_PTR, phy_addr + buf->buf_size - 8);

    _SET_ST_REG_MASK(CONTROL, MEM_BUFCTRL_INIT);
    _CLR_ST_REG_MASK(CONTROL, MEM_BUFCTRL_INIT);

    _WRITE_ST_REG(BUF_CTRL, MEM_BUFCTRL_MANUAL);
    _WRITE_ST_REG(WP, phy_addr);

    _SET_ST_REG_MASK(BUF_CTRL, MEM_BUFCTRL_INIT);
    _CLR_ST_REG_MASK(BUF_CTRL, MEM_BUFCTRL_INIT);

    _SET_ST_REG_MASK(CONTROL, MEM_FILL_ON_LEVEL | MEM_CTRL_FILL_EN | MEM_CTRL_EMPTY_EN);

    return 0;
}
コード例 #2
0
int stbuf_change_size(struct stream_buf_s *buf, int size)
{
    u32 old_buf, old_size;
    int ret;

    printk("buffersize=%d,%d,start=%x\n", size, buf->buf_size, buf->buf_start);

    if (buf->buf_size == size && buf->buf_start != 0) {
        return 0;
    }

    old_buf = buf->buf_start;
    old_size = buf->buf_size;

    buf->buf_start = 0;
    buf->buf_size = size;
    ret = size;

    if (size == 0 || ((ret = _stbuf_alloc(buf)) == 0)) {
        /*
         * size=0:We only free the old memory;
         * alloc ok,changed to new buffer
         */
        if (old_buf != 0) {
            free_pages(old_buf, get_order(old_size));
        }

        printk("changed the (%d) buffer size from %d to %d\n", buf->type, old_size, size);
    } else {
        /* alloc failed */
        buf->buf_start = old_buf;
        buf->buf_size = old_size;
        printk("changed the (%d) buffer size from %d to %d,failed\n", buf->type, old_size, size);
    }

    return ret;
}
コード例 #3
0
s32 stbuf_init(struct stream_buf_s *buf)
{
    s32 r;
    u32 dummy;
    u32 phy_addr;

    if (buf->flag & BUF_FLAG_IOMEM) {
        phy_addr = buf->buf_start;
    } else {
        r = _stbuf_alloc(buf);
        if (r < 0) {
            return r;
        }
        phy_addr = virt_to_phys((void *)buf->buf_start);
    }

    init_waitqueue_head(&buf->wq);

#if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON8
    if (HAS_HEVC_VDEC && buf->type == BUF_TYPE_HEVC) {
        CLEAR_VREG_MASK(HEVC_STREAM_CONTROL, 1);
        WRITE_VREG(HEVC_STREAM_START_ADDR, phy_addr);
        WRITE_VREG(HEVC_STREAM_END_ADDR, phy_addr + buf->buf_size);
        WRITE_VREG(HEVC_STREAM_RD_PTR, phy_addr);
        WRITE_VREG(HEVC_STREAM_WR_PTR, phy_addr);

        return 0;
    }
#endif

    if (buf->type == BUF_TYPE_VIDEO) {
        _WRITE_ST_REG(CONTROL, 0);
        /* reset VLD before setting all pointers */
        WRITE_VREG(VLD_MEM_VIFIFO_WRAP_COUNT,0);
#if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6
        WRITE_VREG(DOS_SW_RESET0, (1<<4));
        WRITE_VREG(DOS_SW_RESET0, 0);
#else
        WRITE_MPEG_REG(RESET0_REGISTER, RESET_VLD);
#endif
        dummy = READ_MPEG_REG(RESET0_REGISTER);
        WRITE_VREG(POWER_CTL_VLD, 1 << 4);
    } else if (buf->type == BUF_TYPE_AUDIO) {
        _WRITE_ST_REG(CONTROL, 0);

        WRITE_MPEG_REG(AIU_AIFIFO_GBIT, 0x80);
    }

    if (buf->type == BUF_TYPE_SUBTITLE) {
        WRITE_MPEG_REG(PARSER_SUB_RP, phy_addr);
        WRITE_MPEG_REG(PARSER_SUB_START_PTR, phy_addr);
        WRITE_MPEG_REG(PARSER_SUB_END_PTR, phy_addr + buf->buf_size - 8);

        return 0;
    }

    _WRITE_ST_REG(START_PTR, phy_addr);
    _WRITE_ST_REG(CURR_PTR, phy_addr);
    _WRITE_ST_REG(END_PTR, phy_addr + buf->buf_size - 8);

    _SET_ST_REG_MASK(CONTROL, MEM_BUFCTRL_INIT);
    _CLR_ST_REG_MASK(CONTROL, MEM_BUFCTRL_INIT);

    _WRITE_ST_REG(BUF_CTRL, MEM_BUFCTRL_MANUAL);
    _WRITE_ST_REG(WP, phy_addr);

    _SET_ST_REG_MASK(BUF_CTRL, MEM_BUFCTRL_INIT);
    _CLR_ST_REG_MASK(BUF_CTRL, MEM_BUFCTRL_INIT);

    _SET_ST_REG_MASK(CONTROL, (0x11 << 16) | MEM_FILL_ON_LEVEL | MEM_CTRL_FILL_EN | MEM_CTRL_EMPTY_EN);

    return 0;
}