123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730 |
- /* Copyright (c) 2012-2014, The Linux Foundation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 and
- * only version 2 as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
- #include <linux/module.h>
- #include <linux/interrupt.h>
- #include <linux/spinlock.h>
- #include <linux/delay.h>
- #include <linux/io.h>
- #include <linux/dma-mapping.h>
- #include <linux/slab.h>
- #include <linux/iopoll.h>
- #include <linux/kthread.h>
- #include <mach/iommu_domains.h>
- #include "mdss_dsi_cmd.h"
- #include "mdss_dsi.h"
- /*
- * mipi dsi buf mechanism
- */
- char *mdss_dsi_buf_reserve(struct dsi_buf *dp, int len)
- {
- dp->data += len;
- return dp->data;
- }
- char *mdss_dsi_buf_unreserve(struct dsi_buf *dp, int len)
- {
- dp->data -= len;
- return dp->data;
- }
- char *mdss_dsi_buf_push(struct dsi_buf *dp, int len)
- {
- dp->data -= len;
- dp->len += len;
- return dp->data;
- }
- char *mdss_dsi_buf_reserve_hdr(struct dsi_buf *dp, int hlen)
- {
- dp->hdr = (u32 *)dp->data;
- return mdss_dsi_buf_reserve(dp, hlen);
- }
- char *mdss_dsi_buf_init(struct dsi_buf *dp)
- {
- int off;
- dp->data = dp->start;
- off = (int)dp->data;
- /* 8 byte align */
- off &= 0x07;
- if (off)
- off = 8 - off;
- dp->data += off;
- dp->len = 0;
- dp->read_cnt = 0;
- return dp->data;
- }
- int mdss_dsi_buf_alloc(struct dsi_buf *dp, int size)
- {
- #if defined(CONFIG_MACH_S3VE3G_EUR)
- dp->start = dma_alloc_writecombine(NULL, size, &dp->dmap, GFP_KERNEL);
- if (dp->start == NULL) {
- pr_err("%s:%u\n", __func__, __LINE__);
- return -ENOMEM;
- }
- dp->end = dp->start + size;
- dp->size = size;
- if ((int)dp->start & 0x07)
- pr_err("%s: buf NOT 8 bytes aligned\n", __func__);
- dp->data = dp->start;
- dp->len = 0;
- return size;
-
- #else
- int off;
- dp->start = kmalloc(size, GFP_KERNEL);
- if (dp->start == NULL) {
- pr_err("%s:%u\n", __func__, __LINE__);
- return -ENOMEM;
- }
- /* PAGE_SIZE align */
- if ((u32)dp->start & (SZ_4K - 1)) {
- kfree(dp->start);
- dp->start = kmalloc(size * 2, GFP_KERNEL);
- if (dp->start == NULL) {
- pr_err("%s:%u\n", __func__, __LINE__);
- return -ENOMEM;
- }
- off = (int)dp->start;
- off &= (SZ_4K - 1);
- if (off)
- off = SZ_4K - off;
- dp->start += off;
- }
- dp->end = dp->start + size;
- dp->size = size;
- if ((int)dp->start & 0x07)
- pr_err("%s: buf NOT 8 bytes aligned\n", __func__);
- dp->data = dp->start;
- dp->len = 0;
- dp->read_cnt = 0;
- return size;
- #endif
- }
- /*
- * mipi dsi generic long write
- */
- static int mdss_dsi_generic_lwrite(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- char *bp;
- u32 *hp;
- int i, len = 0;
- dchdr = &cm->dchdr;
- bp = mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- /* fill up payload */
- if (cm->payload) {
- len = dchdr->dlen;
- len += 3;
- len &= ~0x03; /* multipled by 4 */
- for (i = 0; i < dchdr->dlen; i++)
- *bp++ = cm->payload[i];
- /* append 0xff to the end */
- for (; i < len; i++)
- *bp++ = 0xff;
- dp->len += len;
- }
- /* fill up header */
- hp = dp->hdr;
- *hp = 0;
- *hp = DSI_HDR_WC(dchdr->dlen);
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_LONG_PKT;
- *hp |= DSI_HDR_DTYPE(DTYPE_GEN_LWRITE);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- len += DSI_HOST_HDR_SIZE;
- return len;
- }
- /*
- * mipi dsi generic short write with 0, 1 2 parameters
- */
- static int mdss_dsi_generic_swrite(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- int len;
- dchdr = &cm->dchdr;
- if (dchdr->dlen && cm->payload == 0) {
- pr_err("%s: NO payload error\n", __func__);
- return 0;
- }
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp |= DSI_HDR_VC(dchdr->vc);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- len = (dchdr->dlen > 2) ? 2 : dchdr->dlen;
- if (len == 1) {
- *hp |= DSI_HDR_DTYPE(DTYPE_GEN_WRITE1);
- *hp |= DSI_HDR_DATA1(cm->payload[0]);
- *hp |= DSI_HDR_DATA2(0);
- } else if (len == 2) {
- *hp |= DSI_HDR_DTYPE(DTYPE_GEN_WRITE2);
- *hp |= DSI_HDR_DATA1(cm->payload[0]);
- *hp |= DSI_HDR_DATA2(cm->payload[1]);
- } else {
- *hp |= DSI_HDR_DTYPE(DTYPE_GEN_WRITE);
- *hp |= DSI_HDR_DATA1(0);
- *hp |= DSI_HDR_DATA2(0);
- }
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- /*
- * mipi dsi gerneric read with 0, 1 2 parameters
- */
- static int mdss_dsi_generic_read(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- int len;
- dchdr = &cm->dchdr;
- if (dchdr->dlen && cm->payload == 0) {
- pr_err("%s: NO payload error\n", __func__);
- return 0;
- }
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_BTA;
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- len = (dchdr->dlen > 2) ? 2 : dchdr->dlen;
- if (len == 1) {
- *hp |= DSI_HDR_DTYPE(DTYPE_GEN_READ1);
- *hp |= DSI_HDR_DATA1(cm->payload[0]);
- *hp |= DSI_HDR_DATA2(0);
- } else if (len == 2) {
- *hp |= DSI_HDR_DTYPE(DTYPE_GEN_READ2);
- *hp |= DSI_HDR_DATA1(cm->payload[0]);
- *hp |= DSI_HDR_DATA2(cm->payload[1]);
- } else {
- *hp |= DSI_HDR_DTYPE(DTYPE_GEN_READ);
- *hp |= DSI_HDR_DATA1(0);
- *hp |= DSI_HDR_DATA2(0);
- }
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- /*
- * mipi dsi dcs long write
- */
- static int mdss_dsi_dcs_lwrite(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- char *bp;
- u32 *hp;
- int i, len = 0;
- dchdr = &cm->dchdr;
- bp = mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- /*
- * fill up payload
- * dcs command byte (first byte) followed by payload
- */
- if (cm->payload) {
- len = dchdr->dlen;
- len += 3;
- len &= ~0x03; /* multipled by 4 */
- for (i = 0; i < dchdr->dlen; i++)
- *bp++ = cm->payload[i];
- /* append 0xff to the end */
- for (; i < len; i++)
- *bp++ = 0xff;
- dp->len += len;
- }
- /* fill up header */
- hp = dp->hdr;
- *hp = 0;
- *hp = DSI_HDR_WC(dchdr->dlen);
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_LONG_PKT;
- *hp |= DSI_HDR_DTYPE(DTYPE_DCS_LWRITE);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- len += DSI_HOST_HDR_SIZE;
- return len;
- }
- /*
- * mipi dsi dcs short write with 0 parameters
- */
- static int mdss_dsi_dcs_swrite(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- int len;
- dchdr = &cm->dchdr;
- if (cm->payload == 0) {
- pr_err("%s: NO payload error\n", __func__);
- return -EINVAL;
- }
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp |= DSI_HDR_VC(dchdr->vc);
- if (dchdr->ack) /* ask ACK trigger msg from peripeheral */
- *hp |= DSI_HDR_BTA;
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- len = (dchdr->dlen > 1) ? 1 : dchdr->dlen;
- *hp |= DSI_HDR_DTYPE(DTYPE_DCS_WRITE);
- *hp |= DSI_HDR_DATA1(cm->payload[0]); /* dcs command byte */
- *hp |= DSI_HDR_DATA2(0);
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- /*
- * mipi dsi dcs short write with 1 parameters
- */
- static int mdss_dsi_dcs_swrite1(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- dchdr = &cm->dchdr;
- if (dchdr->dlen < 2 || cm->payload == 0) {
- pr_err("%s: NO payload error\n", __func__);
- return -EINVAL;
- }
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp |= DSI_HDR_VC(dchdr->vc);
- if (dchdr->ack) /* ask ACK trigger msg from peripeheral */
- *hp |= DSI_HDR_BTA;
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- *hp |= DSI_HDR_DTYPE(DTYPE_DCS_WRITE1);
- *hp |= DSI_HDR_DATA1(cm->payload[0]); /* dcs comamnd byte */
- *hp |= DSI_HDR_DATA2(cm->payload[1]); /* parameter */
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- /*
- * mipi dsi dcs read with 0 parameters
- */
- static int mdss_dsi_dcs_read(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- dchdr = &cm->dchdr;
- if (cm->payload == 0) {
- pr_err("%s: NO payload error\n", __func__);
- return -EINVAL;
- }
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_BTA;
- *hp |= DSI_HDR_DTYPE(DTYPE_DCS_READ);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- *hp |= DSI_HDR_DATA1(cm->payload[0]); /* dcs command byte */
- *hp |= DSI_HDR_DATA2(0);
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- static int mdss_dsi_cm_on(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- dchdr = &cm->dchdr;
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_DTYPE(DTYPE_CM_ON);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- static int mdss_dsi_cm_off(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- dchdr = &cm->dchdr;
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_DTYPE(DTYPE_CM_OFF);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- static int mdss_dsi_peripheral_on(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- dchdr = &cm->dchdr;
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_DTYPE(DTYPE_PERIPHERAL_ON);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- static int mdss_dsi_peripheral_off(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- dchdr = &cm->dchdr;
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_DTYPE(DTYPE_PERIPHERAL_OFF);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- static int mdss_dsi_set_max_pktsize(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- dchdr = &cm->dchdr;
- if (cm->payload == 0) {
- pr_err("%s: NO payload error\n", __func__);
- return 0;
- }
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_DTYPE(DTYPE_MAX_PKTSIZE);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- *hp |= DSI_HDR_DATA1(cm->payload[0]);
- *hp |= DSI_HDR_DATA2(cm->payload[1]);
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- static int mdss_dsi_null_pkt(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- dchdr = &cm->dchdr;
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp = DSI_HDR_WC(dchdr->dlen);
- *hp |= DSI_HDR_LONG_PKT;
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_DTYPE(DTYPE_NULL_PKT);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- static int mdss_dsi_blank_pkt(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- u32 *hp;
- dchdr = &cm->dchdr;
- mdss_dsi_buf_reserve_hdr(dp, DSI_HOST_HDR_SIZE);
- hp = dp->hdr;
- *hp = 0;
- *hp = DSI_HDR_WC(dchdr->dlen);
- *hp |= DSI_HDR_LONG_PKT;
- *hp |= DSI_HDR_VC(dchdr->vc);
- *hp |= DSI_HDR_DTYPE(DTYPE_BLANK_PKT);
- if (dchdr->last)
- *hp |= DSI_HDR_LAST;
- mdss_dsi_buf_push(dp, DSI_HOST_HDR_SIZE);
- return DSI_HOST_HDR_SIZE; /* 4 bytes */
- }
- /*
- * prepare cmd buffer to be txed
- */
- int mdss_dsi_cmd_dma_add(struct dsi_buf *dp, struct dsi_cmd_desc *cm)
- {
- struct dsi_ctrl_hdr *dchdr;
- int len = 0;
- dchdr = &cm->dchdr;
- switch (dchdr->dtype) {
- case DTYPE_GEN_WRITE:
- case DTYPE_GEN_WRITE1:
- case DTYPE_GEN_WRITE2:
- len = mdss_dsi_generic_swrite(dp, cm);
- break;
- case DTYPE_GEN_LWRITE:
- len = mdss_dsi_generic_lwrite(dp, cm);
- break;
- case DTYPE_GEN_READ:
- case DTYPE_GEN_READ1:
- case DTYPE_GEN_READ2:
- len = mdss_dsi_generic_read(dp, cm);
- break;
- case DTYPE_DCS_LWRITE:
- len = mdss_dsi_dcs_lwrite(dp, cm);
- break;
- case DTYPE_DCS_WRITE:
- len = mdss_dsi_dcs_swrite(dp, cm);
- break;
- case DTYPE_DCS_WRITE1:
- len = mdss_dsi_dcs_swrite1(dp, cm);
- break;
- case DTYPE_DCS_READ:
- len = mdss_dsi_dcs_read(dp, cm);
- break;
- case DTYPE_MAX_PKTSIZE:
- len = mdss_dsi_set_max_pktsize(dp, cm);
- break;
- case DTYPE_NULL_PKT:
- len = mdss_dsi_null_pkt(dp, cm);
- break;
- case DTYPE_BLANK_PKT:
- len = mdss_dsi_blank_pkt(dp, cm);
- break;
- case DTYPE_CM_ON:
- len = mdss_dsi_cm_on(dp, cm);
- break;
- case DTYPE_CM_OFF:
- len = mdss_dsi_cm_off(dp, cm);
- break;
- case DTYPE_PERIPHERAL_ON:
- len = mdss_dsi_peripheral_on(dp, cm);
- break;
- case DTYPE_PERIPHERAL_OFF:
- len = mdss_dsi_peripheral_off(dp, cm);
- break;
- default:
- pr_debug("%s: dtype=%x NOT supported\n",
- __func__, dchdr->dtype);
- break;
- }
- return len;
- }
- /*
- * mdss_dsi_short_read1_resp: 1 parameter
- */
- int mdss_dsi_short_read1_resp(struct dsi_buf *rp)
- {
- /* strip out dcs type */
- rp->data++;
- rp->len = 1;
- rp->read_cnt -= 3;
- return rp->len;
- }
- /*
- * mdss_dsi_short_read2_resp: 2 parameter
- */
- int mdss_dsi_short_read2_resp(struct dsi_buf *rp)
- {
- /* strip out dcs type */
- rp->data++;
- rp->len = 2;
- rp->read_cnt -= 2;
- return rp->len;
- }
- int mdss_dsi_long_read_resp(struct dsi_buf *rp)
- {
- /* strip out dcs header */
- rp->data += 4;
- rp->len -= 4;
- rp->read_cnt -= 6;
- return rp->len;
- }
- static char set_tear_on[2] = {0x35, 0x00};
- static struct dsi_cmd_desc dsi_tear_on_cmd = {
- {DTYPE_DCS_WRITE1, 1, 0, 0, 0, sizeof(set_tear_on)}, set_tear_on};
- static char set_tear_off[2] = {0x34, 0x00};
- static struct dsi_cmd_desc dsi_tear_off_cmd = {
- {DTYPE_DCS_WRITE, 1, 0, 0, 0, sizeof(set_tear_off)}, set_tear_off};
- void mdss_dsi_set_tear_on(struct mdss_dsi_ctrl_pdata *ctrl)
- {
- struct dcs_cmd_req cmdreq;
- cmdreq.cmds = &dsi_tear_on_cmd;
- cmdreq.cmds_cnt = 1;
- cmdreq.flags = CMD_REQ_COMMIT;
- cmdreq.rlen = 0;
- cmdreq.cb = NULL;
- mdss_dsi_cmdlist_put(ctrl, &cmdreq);
- }
- void mdss_dsi_set_tear_off(struct mdss_dsi_ctrl_pdata *ctrl)
- {
- struct dcs_cmd_req cmdreq;
- cmdreq.cmds = &dsi_tear_off_cmd;
- cmdreq.cmds_cnt = 1;
- cmdreq.flags = CMD_REQ_COMMIT;
- cmdreq.rlen = 0;
- cmdreq.cb = NULL;
- mdss_dsi_cmdlist_put(ctrl, &cmdreq);
- }
- /*
- * mdss_dsi_cmd_get: ctrl->cmd_mutex acquired by caller
- */
- struct dcs_cmd_req *mdss_dsi_cmdlist_get(struct mdss_dsi_ctrl_pdata *ctrl)
- {
- struct dcs_cmd_list *clist;
- struct dcs_cmd_req *req = NULL;
- clist = &ctrl->cmdlist;
- if (clist->get != clist->put) {
- req = &clist->list[clist->get];
- clist->get++;
- clist->get %= CMD_REQ_MAX;
- clist->tot--;
- pr_debug("%s: tot=%d put=%d get=%d\n", __func__,
- clist->tot, clist->put, clist->get);
- }
- return req;
- }
- int mdss_dsi_cmdlist_put(struct mdss_dsi_ctrl_pdata *ctrl,
- struct dcs_cmd_req *cmdreq)
- {
- struct dcs_cmd_req *req;
- struct dcs_cmd_list *clist;
- int ret = -EINVAL;
- mutex_lock(&ctrl->cmd_mutex);
- clist = &ctrl->cmdlist;
- req = &clist->list[clist->put];
- *req = *cmdreq;
- clist->put++;
- clist->put %= CMD_REQ_MAX;
- clist->tot++;
- if (clist->put == clist->get) {
- /* drop the oldest one */
- pr_debug("%s: DROP, tot=%d put=%d get=%d\n", __func__,
- clist->tot, clist->put, clist->get);
- clist->get++;
- clist->get %= CMD_REQ_MAX;
- clist->tot--;
- }
- mutex_unlock(&ctrl->cmd_mutex);
- pr_debug("%s: tot=%d put=%d get=%d\n", __func__,
- clist->tot, clist->put, clist->get);
- if (req->flags & CMD_REQ_COMMIT) {
- if (!ctrl->cmdlist_commit)
- pr_err("cmdlist_commit not implemented!\n");
- else
- ret = ctrl->cmdlist_commit(ctrl, 0);
- }
- return ret;
- }
|