| .. | .. |
|---|
| 28 | 28 | struct buf_list_s *dsp_buf_list; /* dispplay buffer list. */ |
|---|
| 29 | 29 | int dsp_buf_list_status; |
|---|
| 30 | 30 | struct ebc_buf_s *osd_buf; |
|---|
| 31 | | - struct buf_list_s *osd_buf_list; /* dispplay buffer list. */ |
|---|
| 32 | | - struct mutex osd_buf_lock; |
|---|
| 33 | | - struct mutex dsp_buf_lock; |
|---|
| 34 | | - struct mutex ebc_buf_lock; |
|---|
| 31 | + |
|---|
| 32 | + struct mutex dsp_lock; |
|---|
| 35 | 33 | }; |
|---|
| 36 | 34 | |
|---|
| 37 | 35 | static struct buf_info_s ebc_buf_info; |
|---|
| .. | .. |
|---|
| 56 | 54 | return BUF_SUCCESS; |
|---|
| 57 | 55 | } |
|---|
| 58 | 56 | |
|---|
| 59 | | -static void do_dsp_buf_list(struct ebc_buf_s *dsp_buf) |
|---|
| 57 | +int ebc_remove_from_dsp_buf_list(struct ebc_buf_s *remove_buf) |
|---|
| 60 | 58 | { |
|---|
| 61 | | - struct ebc_buf_s *temp_buf; |
|---|
| 62 | | - int temp_pos; |
|---|
| 63 | | - |
|---|
| 64 | | - if (ebc_buf_info.dsp_buf_list->nb_elt > 0) { |
|---|
| 65 | | - temp_pos = ebc_buf_info.dsp_buf_list->nb_elt; |
|---|
| 66 | | - while (temp_pos) { |
|---|
| 67 | | - temp_pos--; |
|---|
| 68 | | - temp_buf = (struct ebc_buf_s *)buf_list_get(ebc_buf_info.dsp_buf_list, temp_pos); |
|---|
| 69 | | - if (temp_buf->needpic) { |
|---|
| 70 | | - continue; |
|---|
| 71 | | - } else { |
|---|
| 72 | | - buf_list_remove(ebc_buf_info.dsp_buf_list, temp_pos); |
|---|
| 73 | | - ebc_buf_release(temp_buf); |
|---|
| 74 | | - } |
|---|
| 75 | | - } |
|---|
| 76 | | - } |
|---|
| 77 | | -} |
|---|
| 78 | | - |
|---|
| 79 | | -int ebc_drop_one_dsp_buf(void) |
|---|
| 80 | | -{ |
|---|
| 81 | | - struct ebc_buf_s *temp_buf; |
|---|
| 82 | | - int temp_pos; |
|---|
| 83 | | - |
|---|
| 84 | | - mutex_lock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 59 | + mutex_lock(&ebc_buf_info.dsp_lock); |
|---|
| 85 | 60 | if (ebc_buf_info.dsp_buf_list) { |
|---|
| 86 | | - if (ebc_buf_info.dsp_buf_list->nb_elt > 0) { |
|---|
| 87 | | - temp_pos = ebc_buf_info.dsp_buf_list->nb_elt - 1; |
|---|
| 88 | | - temp_buf = (struct ebc_buf_s *)buf_list_get(ebc_buf_info.dsp_buf_list, temp_pos); |
|---|
| 89 | | - if (temp_buf->needpic == 2) { |
|---|
| 90 | | - buf_list_remove(ebc_buf_info.dsp_buf_list, temp_pos); |
|---|
| 91 | | - ebc_buf_release(temp_buf); |
|---|
| 92 | | - mutex_unlock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 93 | | - return BUF_SUCCESS; |
|---|
| 94 | | - } |
|---|
| 95 | | - } |
|---|
| 61 | + int pos; |
|---|
| 62 | + |
|---|
| 63 | + pos = buf_list_get_pos(ebc_buf_info.dsp_buf_list, (int *)remove_buf); |
|---|
| 64 | + buf_list_remove(ebc_buf_info.dsp_buf_list, pos); |
|---|
| 96 | 65 | } |
|---|
| 97 | | - mutex_unlock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 98 | | - |
|---|
| 99 | | - return BUF_ERROR; |
|---|
| 100 | | -} |
|---|
| 101 | | - |
|---|
| 102 | | -int ebc_add_to_dsp_buf_list(struct ebc_buf_s *dsp_buf) |
|---|
| 103 | | -{ |
|---|
| 104 | | - mutex_lock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 105 | | - if (ebc_buf_info.dsp_buf_list) { |
|---|
| 106 | | - do_dsp_buf_list(dsp_buf); |
|---|
| 107 | | - |
|---|
| 108 | | - if (-1 == buf_list_add(ebc_buf_info.dsp_buf_list, (int *)dsp_buf, -1)) { |
|---|
| 109 | | - ebc_buf_release(dsp_buf); |
|---|
| 110 | | - mutex_unlock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 111 | | - return BUF_ERROR; |
|---|
| 112 | | - } |
|---|
| 113 | | - |
|---|
| 114 | | - if (dsp_buf->status != buf_osd) |
|---|
| 115 | | - dsp_buf->status = buf_dsp; |
|---|
| 116 | | - } |
|---|
| 117 | | - mutex_unlock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 66 | + mutex_unlock(&ebc_buf_info.dsp_lock); |
|---|
| 118 | 67 | |
|---|
| 119 | 68 | return BUF_SUCCESS; |
|---|
| 120 | 69 | } |
|---|
| 121 | 70 | |
|---|
| 122 | | -int ebc_add_to_osd_buf_list(struct ebc_buf_s *dsp_buf) |
|---|
| 71 | +int ebc_add_to_dsp_buf_list(struct ebc_buf_s *dsp_buf) |
|---|
| 123 | 72 | { |
|---|
| 124 | | - int ret = BUF_SUCCESS; |
|---|
| 73 | + struct ebc_buf_s *temp_buf; |
|---|
| 74 | + int temp_pos; |
|---|
| 75 | + int is_full_mode = 0; |
|---|
| 125 | 76 | |
|---|
| 126 | | - mutex_lock(&ebc_buf_info.osd_buf_lock); |
|---|
| 127 | | - if (ebc_buf_info.osd_buf_list) { |
|---|
| 128 | | - if (-1 == buf_list_add(ebc_buf_info.osd_buf_list, (int *)dsp_buf, -1)) { |
|---|
| 129 | | - ebc_buf_release(dsp_buf); |
|---|
| 130 | | - ret = BUF_ERROR; |
|---|
| 77 | + mutex_lock(&ebc_buf_info.dsp_lock); |
|---|
| 78 | + if (ebc_buf_info.dsp_buf_list) { |
|---|
| 79 | + switch (dsp_buf->buf_mode) { |
|---|
| 80 | + case EPD_DU: |
|---|
| 81 | + case EPD_SUSPEND: |
|---|
| 82 | + case EPD_RESUME: |
|---|
| 83 | + case EPD_POWER_OFF: |
|---|
| 84 | + case EPD_OVERLAY: |
|---|
| 85 | + case EPD_RESET: |
|---|
| 86 | + break; |
|---|
| 87 | + |
|---|
| 88 | + default: |
|---|
| 89 | + if (ebc_buf_info.dsp_buf_list->nb_elt > 1) { |
|---|
| 90 | + temp_pos = ebc_buf_info.dsp_buf_list->nb_elt; |
|---|
| 91 | + while (--temp_pos) { |
|---|
| 92 | + temp_buf = (struct ebc_buf_s *)buf_list_get(ebc_buf_info.dsp_buf_list, temp_pos); |
|---|
| 93 | + if ((temp_buf->buf_mode != EPD_FULL_GC16) && |
|---|
| 94 | + (temp_buf->buf_mode != EPD_FULL_GL16) && |
|---|
| 95 | + (temp_buf->buf_mode != EPD_FULL_GLR16) && |
|---|
| 96 | + (temp_buf->buf_mode != EPD_FULL_GLD16) && |
|---|
| 97 | + (temp_buf->buf_mode != EPD_FULL_GCC16) && |
|---|
| 98 | + (temp_buf->buf_mode != EPD_OVERLAY) && |
|---|
| 99 | + (temp_buf->buf_mode != EPD_DU) && |
|---|
| 100 | + (temp_buf->buf_mode != EPD_SUSPEND) && |
|---|
| 101 | + (temp_buf->buf_mode != EPD_RESUME) && |
|---|
| 102 | + (temp_buf->buf_mode != EPD_POWER_OFF)) { |
|---|
| 103 | + buf_list_remove(ebc_buf_info.dsp_buf_list, temp_pos); |
|---|
| 104 | + ebc_buf_release(temp_buf); |
|---|
| 105 | + } else if ((1 == is_full_mode) && |
|---|
| 106 | + (temp_buf->buf_mode != EPD_DU) && |
|---|
| 107 | + (temp_buf->buf_mode != EPD_OVERLAY) && |
|---|
| 108 | + (temp_buf->buf_mode != EPD_SUSPEND) && |
|---|
| 109 | + (temp_buf->buf_mode != EPD_RESUME) && |
|---|
| 110 | + (temp_buf->buf_mode != EPD_POWER_OFF)) { |
|---|
| 111 | + buf_list_remove(ebc_buf_info.dsp_buf_list, temp_pos); |
|---|
| 112 | + ebc_buf_release(temp_buf); |
|---|
| 113 | + } else { |
|---|
| 114 | + is_full_mode = 1; |
|---|
| 115 | + } |
|---|
| 116 | + } |
|---|
| 117 | + } |
|---|
| 118 | + break; |
|---|
| 119 | + } |
|---|
| 120 | + |
|---|
| 121 | + dsp_buf->status = buf_dsp; |
|---|
| 122 | + if (-1 == buf_list_add(ebc_buf_info.dsp_buf_list, (int *)dsp_buf, -1)) { |
|---|
| 123 | + mutex_unlock(&ebc_buf_info.dsp_lock); |
|---|
| 124 | + return BUF_ERROR; |
|---|
| 131 | 125 | } |
|---|
| 132 | 126 | } |
|---|
| 133 | | - mutex_unlock(&ebc_buf_info.osd_buf_lock); |
|---|
| 134 | | - return ret; |
|---|
| 135 | | -} |
|---|
| 127 | + mutex_unlock(&ebc_buf_info.dsp_lock); |
|---|
| 136 | 128 | |
|---|
| 137 | | -struct ebc_buf_s *ebc_osd_buf_get(void) |
|---|
| 138 | | -{ |
|---|
| 139 | | - struct ebc_buf_s *buf = NULL; |
|---|
| 140 | | - |
|---|
| 141 | | - mutex_lock(&ebc_buf_info.osd_buf_lock); |
|---|
| 142 | | - if (ebc_buf_info.osd_buf_list && (ebc_buf_info.osd_buf_list->nb_elt > 0)) { |
|---|
| 143 | | - buf = (struct ebc_buf_s *)buf_list_get(ebc_buf_info.osd_buf_list, 0); |
|---|
| 144 | | - buf_list_remove(ebc_buf_info.osd_buf_list, 0); |
|---|
| 145 | | - } |
|---|
| 146 | | - mutex_unlock(&ebc_buf_info.osd_buf_lock); |
|---|
| 147 | | - |
|---|
| 148 | | - return buf; |
|---|
| 129 | + return BUF_SUCCESS; |
|---|
| 149 | 130 | } |
|---|
| 150 | 131 | |
|---|
| 151 | 132 | int ebc_get_dsp_list_enum_num(void) |
|---|
| 152 | 133 | { |
|---|
| 153 | 134 | return ebc_buf_info.dsp_buf_list->nb_elt; |
|---|
| 154 | | -} |
|---|
| 155 | | - |
|---|
| 156 | | -int ebc_get_osd_list_enum_num(void) |
|---|
| 157 | | -{ |
|---|
| 158 | | - return ebc_buf_info.osd_buf_list->nb_elt; |
|---|
| 159 | 135 | } |
|---|
| 160 | 136 | |
|---|
| 161 | 137 | struct ebc_buf_s *ebc_find_buf_by_phy_addr(unsigned long phy_addr) |
|---|
| .. | .. |
|---|
| 179 | 155 | { |
|---|
| 180 | 156 | struct ebc_buf_s *buf = NULL; |
|---|
| 181 | 157 | |
|---|
| 182 | | - mutex_lock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 183 | | - if (ebc_buf_info.dsp_buf_list && (ebc_buf_info.dsp_buf_list->nb_elt > 0)) { |
|---|
| 158 | + mutex_lock(&ebc_buf_info.dsp_lock); |
|---|
| 159 | + if (ebc_buf_info.dsp_buf_list && (ebc_buf_info.dsp_buf_list->nb_elt > 0)) |
|---|
| 184 | 160 | buf = (struct ebc_buf_s *)buf_list_get(ebc_buf_info.dsp_buf_list, 0); |
|---|
| 185 | | - buf_list_remove(ebc_buf_info.dsp_buf_list, 0); |
|---|
| 186 | | - } |
|---|
| 187 | | - mutex_unlock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 161 | + mutex_unlock(&ebc_buf_info.dsp_lock); |
|---|
| 188 | 162 | |
|---|
| 189 | 163 | return buf; |
|---|
| 190 | 164 | } |
|---|
| 191 | 165 | |
|---|
| 192 | | -struct ebc_buf_s *ebc_empty_osd_buf_get(void) |
|---|
| 166 | +struct ebc_buf_s *ebc_osd_buf_get(void) |
|---|
| 193 | 167 | { |
|---|
| 194 | 168 | if (ebc_buf_info.osd_buf) |
|---|
| 195 | 169 | return ebc_buf_info.osd_buf; |
|---|
| .. | .. |
|---|
| 211 | 185 | return temp_buf; |
|---|
| 212 | 186 | } |
|---|
| 213 | 187 | |
|---|
| 214 | | -struct ebc_buf_s *ebc_empty_buf_get(const char *tid_name) |
|---|
| 188 | +struct ebc_buf_s *ebc_empty_buf_get(void) |
|---|
| 215 | 189 | { |
|---|
| 216 | | - struct ebc_buf_s *temp_buf = NULL; |
|---|
| 190 | + struct ebc_buf_s *temp_buf; |
|---|
| 217 | 191 | int temp_pos; |
|---|
| 218 | 192 | |
|---|
| 219 | | - mutex_lock(&ebc_buf_info.ebc_buf_lock); |
|---|
| 220 | | - while (ebc_buf_info.buf_list) { |
|---|
| 193 | + if (ebc_buf_info.buf_list) { |
|---|
| 221 | 194 | temp_pos = 0; |
|---|
| 222 | 195 | |
|---|
| 223 | 196 | while (temp_pos < ebc_buf_info.buf_list->nb_elt) { |
|---|
| .. | .. |
|---|
| 225 | 198 | if (temp_buf) { |
|---|
| 226 | 199 | if (temp_buf->status == buf_idle) { |
|---|
| 227 | 200 | temp_buf->status = buf_user; |
|---|
| 228 | | - memcpy(temp_buf->tid_name, tid_name, TASK_COMM_LEN - 1); //store user thread name |
|---|
| 229 | | - goto OUT; |
|---|
| 201 | + memcpy(temp_buf->tid_name, current->comm, TASK_COMM_LEN); //store user thread name |
|---|
| 202 | + return temp_buf; |
|---|
| 230 | 203 | } |
|---|
| 231 | 204 | // one tid only can get one buf at one time |
|---|
| 232 | | - else if ((temp_buf->status == buf_user) && (!strncmp(temp_buf->tid_name, tid_name, TASK_COMM_LEN - 1))) { |
|---|
| 233 | | - printk("[%s]: one tid only can get one buf at one time\n", tid_name); |
|---|
| 234 | | - goto OUT; |
|---|
| 205 | + else if ((temp_buf->status == buf_user) && (!strncmp(temp_buf->tid_name, current->comm, TASK_COMM_LEN - 7))) { |
|---|
| 206 | + return temp_buf; |
|---|
| 235 | 207 | } |
|---|
| 236 | 208 | } |
|---|
| 237 | 209 | } |
|---|
| 238 | 210 | ebc_buf_info.use_buf_is_empty = 1; |
|---|
| 211 | + |
|---|
| 239 | 212 | wait_event_interruptible(ebc_buf_wq, ebc_buf_info.use_buf_is_empty != 1); |
|---|
| 213 | + |
|---|
| 214 | + return ebc_empty_buf_get(); |
|---|
| 240 | 215 | } |
|---|
| 241 | 216 | |
|---|
| 242 | | -OUT: |
|---|
| 243 | | - mutex_unlock(&ebc_buf_info.ebc_buf_lock); |
|---|
| 244 | | - return temp_buf; |
|---|
| 217 | + return NULL; |
|---|
| 245 | 218 | } |
|---|
| 246 | 219 | |
|---|
| 247 | 220 | unsigned long ebc_phy_buf_base_get(void) |
|---|
| .. | .. |
|---|
| 252 | 225 | char *ebc_virt_buf_base_get(void) |
|---|
| 253 | 226 | { |
|---|
| 254 | 227 | return ebc_buf_info.virt_mem_base; |
|---|
| 255 | | -} |
|---|
| 256 | | - |
|---|
| 257 | | -int ebc_buf_state_show(char *buf) |
|---|
| 258 | | -{ |
|---|
| 259 | | - int i; |
|---|
| 260 | | - int ret = 0; |
|---|
| 261 | | - struct ebc_buf_s *temp_buf; |
|---|
| 262 | | - |
|---|
| 263 | | - ret += sprintf(buf, "dsp_buf num = %d\n", ebc_buf_info.dsp_buf_list->nb_elt); |
|---|
| 264 | | - if (ebc_buf_info.buf_list) { |
|---|
| 265 | | - for (i = 0; i < ebc_buf_info.buf_list->nb_elt; i++) { |
|---|
| 266 | | - temp_buf = (struct ebc_buf_s *)buf_list_get(ebc_buf_info.buf_list, i); |
|---|
| 267 | | - ret += sprintf(buf + ret, "ebc_buf[%d]: s = %d, m = %d, tid = %s\n", i, temp_buf->status, temp_buf->buf_mode, temp_buf->tid_name); |
|---|
| 268 | | - } |
|---|
| 269 | | - } |
|---|
| 270 | | - |
|---|
| 271 | | - return ret; |
|---|
| 272 | 228 | } |
|---|
| 273 | 229 | |
|---|
| 274 | 230 | int ebc_buf_uninit(void) |
|---|
| .. | .. |
|---|
| 304 | 260 | if (NULL == mem_start) |
|---|
| 305 | 261 | return BUF_ERROR; |
|---|
| 306 | 262 | |
|---|
| 307 | | - mutex_init(&ebc_buf_info.dsp_buf_lock); |
|---|
| 308 | | - mutex_init(&ebc_buf_info.ebc_buf_lock); |
|---|
| 309 | | - mutex_init(&ebc_buf_info.osd_buf_lock); |
|---|
| 263 | + mutex_init(&ebc_buf_info.dsp_lock); |
|---|
| 310 | 264 | |
|---|
| 311 | 265 | if (buf_list_init(&ebc_buf_info.buf_list, BUF_LIST_MAX_NUMBER)) |
|---|
| 312 | 266 | return BUF_ERROR; |
|---|
| 313 | 267 | |
|---|
| 314 | 268 | if (buf_list_init(&ebc_buf_info.dsp_buf_list, BUF_LIST_MAX_NUMBER)) { |
|---|
| 315 | 269 | res = BUF_ERROR; |
|---|
| 316 | | - goto dsp_list_err; |
|---|
| 317 | | - } |
|---|
| 318 | | - |
|---|
| 319 | | - if (buf_list_init(&ebc_buf_info.osd_buf_list, BUF_LIST_MAX_NUMBER)) { |
|---|
| 320 | | - res = BUF_ERROR; |
|---|
| 321 | | - goto osd_list_err; |
|---|
| 270 | + goto buf_list_err; |
|---|
| 322 | 271 | } |
|---|
| 323 | 272 | |
|---|
| 324 | 273 | ebc_buf_info.buf_total_num = 0; |
|---|
| .. | .. |
|---|
| 368 | 317 | } |
|---|
| 369 | 318 | |
|---|
| 370 | 319 | return BUF_SUCCESS; |
|---|
| 371 | | - |
|---|
| 372 | 320 | exit: |
|---|
| 373 | 321 | ebc_buf_uninit(); |
|---|
| 374 | | - buf_list_uninit(ebc_buf_info.osd_buf_list); |
|---|
| 375 | | -osd_list_err: |
|---|
| 376 | 322 | buf_list_uninit(ebc_buf_info.dsp_buf_list); |
|---|
| 377 | | -dsp_list_err: |
|---|
| 323 | +buf_list_err: |
|---|
| 378 | 324 | buf_list_uninit(ebc_buf_info.buf_list); |
|---|
| 379 | 325 | |
|---|
| 380 | 326 | return res; |
|---|