| .. | .. |
|---|
| 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_add_to_dsp_buf_list(struct ebc_buf_s *dsp_buf) |
|---|
| 80 | | -{ |
|---|
| 81 | | - mutex_lock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 59 | + mutex_lock(&ebc_buf_info.dsp_lock); |
|---|
| 82 | 60 | if (ebc_buf_info.dsp_buf_list) { |
|---|
| 83 | | - do_dsp_buf_list(dsp_buf); |
|---|
| 61 | + int pos; |
|---|
| 84 | 62 | |
|---|
| 85 | | - if (-1 == buf_list_add(ebc_buf_info.dsp_buf_list, (int *)dsp_buf, -1)) { |
|---|
| 86 | | - ebc_buf_release(dsp_buf); |
|---|
| 87 | | - mutex_unlock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 88 | | - return BUF_ERROR; |
|---|
| 89 | | - } |
|---|
| 90 | | - |
|---|
| 91 | | - if (dsp_buf->status != buf_osd) |
|---|
| 92 | | - dsp_buf->status = buf_dsp; |
|---|
| 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); |
|---|
| 93 | 65 | } |
|---|
| 94 | | - mutex_unlock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 66 | + mutex_unlock(&ebc_buf_info.dsp_lock); |
|---|
| 95 | 67 | |
|---|
| 96 | 68 | return BUF_SUCCESS; |
|---|
| 97 | 69 | } |
|---|
| 98 | 70 | |
|---|
| 99 | | -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) |
|---|
| 100 | 72 | { |
|---|
| 101 | | - int ret = BUF_SUCCESS; |
|---|
| 73 | + struct ebc_buf_s *temp_buf; |
|---|
| 74 | + int temp_pos; |
|---|
| 75 | + int is_full_mode = 0; |
|---|
| 102 | 76 | |
|---|
| 103 | | - mutex_lock(&ebc_buf_info.osd_buf_lock); |
|---|
| 104 | | - if (ebc_buf_info.osd_buf_list) { |
|---|
| 105 | | - if (-1 == buf_list_add(ebc_buf_info.osd_buf_list, (int *)dsp_buf, -1)) { |
|---|
| 106 | | - ebc_buf_release(dsp_buf); |
|---|
| 107 | | - 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; |
|---|
| 108 | 125 | } |
|---|
| 109 | 126 | } |
|---|
| 110 | | - mutex_unlock(&ebc_buf_info.osd_buf_lock); |
|---|
| 111 | | - return ret; |
|---|
| 112 | | -} |
|---|
| 127 | + mutex_unlock(&ebc_buf_info.dsp_lock); |
|---|
| 113 | 128 | |
|---|
| 114 | | -struct ebc_buf_s *ebc_osd_buf_get(void) |
|---|
| 115 | | -{ |
|---|
| 116 | | - struct ebc_buf_s *buf = NULL; |
|---|
| 117 | | - |
|---|
| 118 | | - mutex_lock(&ebc_buf_info.osd_buf_lock); |
|---|
| 119 | | - if (ebc_buf_info.osd_buf_list && (ebc_buf_info.osd_buf_list->nb_elt > 0)) { |
|---|
| 120 | | - buf = (struct ebc_buf_s *)buf_list_get(ebc_buf_info.osd_buf_list, 0); |
|---|
| 121 | | - buf_list_remove(ebc_buf_info.osd_buf_list, 0); |
|---|
| 122 | | - } |
|---|
| 123 | | - mutex_unlock(&ebc_buf_info.osd_buf_lock); |
|---|
| 124 | | - |
|---|
| 125 | | - return buf; |
|---|
| 129 | + return BUF_SUCCESS; |
|---|
| 126 | 130 | } |
|---|
| 127 | 131 | |
|---|
| 128 | 132 | int ebc_get_dsp_list_enum_num(void) |
|---|
| 129 | 133 | { |
|---|
| 130 | 134 | return ebc_buf_info.dsp_buf_list->nb_elt; |
|---|
| 131 | | -} |
|---|
| 132 | | - |
|---|
| 133 | | -int ebc_get_osd_list_enum_num(void) |
|---|
| 134 | | -{ |
|---|
| 135 | | - return ebc_buf_info.osd_buf_list->nb_elt; |
|---|
| 136 | 135 | } |
|---|
| 137 | 136 | |
|---|
| 138 | 137 | struct ebc_buf_s *ebc_find_buf_by_phy_addr(unsigned long phy_addr) |
|---|
| .. | .. |
|---|
| 156 | 155 | { |
|---|
| 157 | 156 | struct ebc_buf_s *buf = NULL; |
|---|
| 158 | 157 | |
|---|
| 159 | | - mutex_lock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 160 | | - 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)) |
|---|
| 161 | 160 | buf = (struct ebc_buf_s *)buf_list_get(ebc_buf_info.dsp_buf_list, 0); |
|---|
| 162 | | - buf_list_remove(ebc_buf_info.dsp_buf_list, 0); |
|---|
| 163 | | - } |
|---|
| 164 | | - mutex_unlock(&ebc_buf_info.dsp_buf_lock); |
|---|
| 161 | + mutex_unlock(&ebc_buf_info.dsp_lock); |
|---|
| 165 | 162 | |
|---|
| 166 | 163 | return buf; |
|---|
| 167 | 164 | } |
|---|
| 168 | 165 | |
|---|
| 169 | | -struct ebc_buf_s *ebc_empty_osd_buf_get(void) |
|---|
| 166 | +struct ebc_buf_s *ebc_osd_buf_get(void) |
|---|
| 170 | 167 | { |
|---|
| 171 | 168 | if (ebc_buf_info.osd_buf) |
|---|
| 172 | 169 | return ebc_buf_info.osd_buf; |
|---|
| .. | .. |
|---|
| 188 | 185 | return temp_buf; |
|---|
| 189 | 186 | } |
|---|
| 190 | 187 | |
|---|
| 191 | | -struct ebc_buf_s *ebc_empty_buf_get(const char *tid_name) |
|---|
| 188 | +struct ebc_buf_s *ebc_empty_buf_get(void) |
|---|
| 192 | 189 | { |
|---|
| 193 | | - struct ebc_buf_s *temp_buf = NULL; |
|---|
| 190 | + struct ebc_buf_s *temp_buf; |
|---|
| 194 | 191 | int temp_pos; |
|---|
| 195 | 192 | |
|---|
| 196 | | - mutex_lock(&ebc_buf_info.ebc_buf_lock); |
|---|
| 197 | | - while (ebc_buf_info.buf_list) { |
|---|
| 193 | + if (ebc_buf_info.buf_list) { |
|---|
| 198 | 194 | temp_pos = 0; |
|---|
| 199 | 195 | |
|---|
| 200 | 196 | while (temp_pos < ebc_buf_info.buf_list->nb_elt) { |
|---|
| .. | .. |
|---|
| 202 | 198 | if (temp_buf) { |
|---|
| 203 | 199 | if (temp_buf->status == buf_idle) { |
|---|
| 204 | 200 | temp_buf->status = buf_user; |
|---|
| 205 | | - memcpy(temp_buf->tid_name, tid_name, TASK_COMM_LEN - 1); //store user thread name |
|---|
| 206 | | - goto OUT; |
|---|
| 201 | + memcpy(temp_buf->tid_name, current->comm, TASK_COMM_LEN); //store user thread name |
|---|
| 202 | + return temp_buf; |
|---|
| 207 | 203 | } |
|---|
| 208 | 204 | // one tid only can get one buf at one time |
|---|
| 209 | | - else if ((temp_buf->status == buf_user) && (!strncmp(temp_buf->tid_name, tid_name, TASK_COMM_LEN - 1))) { |
|---|
| 210 | | - printk("[%s]: one tid only can get one buf at one time\n", tid_name); |
|---|
| 211 | | - 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; |
|---|
| 212 | 207 | } |
|---|
| 213 | 208 | } |
|---|
| 214 | 209 | } |
|---|
| 215 | 210 | ebc_buf_info.use_buf_is_empty = 1; |
|---|
| 211 | + |
|---|
| 216 | 212 | wait_event_interruptible(ebc_buf_wq, ebc_buf_info.use_buf_is_empty != 1); |
|---|
| 213 | + |
|---|
| 214 | + return ebc_empty_buf_get(); |
|---|
| 217 | 215 | } |
|---|
| 218 | 216 | |
|---|
| 219 | | -OUT: |
|---|
| 220 | | - mutex_unlock(&ebc_buf_info.ebc_buf_lock); |
|---|
| 221 | | - return temp_buf; |
|---|
| 217 | + return NULL; |
|---|
| 222 | 218 | } |
|---|
| 223 | 219 | |
|---|
| 224 | 220 | unsigned long ebc_phy_buf_base_get(void) |
|---|
| .. | .. |
|---|
| 229 | 225 | char *ebc_virt_buf_base_get(void) |
|---|
| 230 | 226 | { |
|---|
| 231 | 227 | return ebc_buf_info.virt_mem_base; |
|---|
| 232 | | -} |
|---|
| 233 | | - |
|---|
| 234 | | -int ebc_buf_state_show(char *buf) |
|---|
| 235 | | -{ |
|---|
| 236 | | - int i; |
|---|
| 237 | | - int ret = 0; |
|---|
| 238 | | - struct ebc_buf_s *temp_buf; |
|---|
| 239 | | - |
|---|
| 240 | | - ret += sprintf(buf, "dsp_buf num = %d\n", ebc_buf_info.dsp_buf_list->nb_elt); |
|---|
| 241 | | - if (ebc_buf_info.buf_list) { |
|---|
| 242 | | - for (i = 0; i < ebc_buf_info.buf_list->nb_elt; i++) { |
|---|
| 243 | | - temp_buf = (struct ebc_buf_s *)buf_list_get(ebc_buf_info.buf_list, i); |
|---|
| 244 | | - 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); |
|---|
| 245 | | - } |
|---|
| 246 | | - } |
|---|
| 247 | | - |
|---|
| 248 | | - return ret; |
|---|
| 249 | 228 | } |
|---|
| 250 | 229 | |
|---|
| 251 | 230 | int ebc_buf_uninit(void) |
|---|
| .. | .. |
|---|
| 281 | 260 | if (NULL == mem_start) |
|---|
| 282 | 261 | return BUF_ERROR; |
|---|
| 283 | 262 | |
|---|
| 284 | | - mutex_init(&ebc_buf_info.dsp_buf_lock); |
|---|
| 285 | | - mutex_init(&ebc_buf_info.ebc_buf_lock); |
|---|
| 286 | | - mutex_init(&ebc_buf_info.osd_buf_lock); |
|---|
| 263 | + mutex_init(&ebc_buf_info.dsp_lock); |
|---|
| 287 | 264 | |
|---|
| 288 | 265 | if (buf_list_init(&ebc_buf_info.buf_list, BUF_LIST_MAX_NUMBER)) |
|---|
| 289 | 266 | return BUF_ERROR; |
|---|
| 290 | 267 | |
|---|
| 291 | 268 | if (buf_list_init(&ebc_buf_info.dsp_buf_list, BUF_LIST_MAX_NUMBER)) { |
|---|
| 292 | 269 | res = BUF_ERROR; |
|---|
| 293 | | - goto dsp_list_err; |
|---|
| 294 | | - } |
|---|
| 295 | | - |
|---|
| 296 | | - if (buf_list_init(&ebc_buf_info.osd_buf_list, BUF_LIST_MAX_NUMBER)) { |
|---|
| 297 | | - res = BUF_ERROR; |
|---|
| 298 | | - goto osd_list_err; |
|---|
| 270 | + goto buf_list_err; |
|---|
| 299 | 271 | } |
|---|
| 300 | 272 | |
|---|
| 301 | 273 | ebc_buf_info.buf_total_num = 0; |
|---|
| .. | .. |
|---|
| 345 | 317 | } |
|---|
| 346 | 318 | |
|---|
| 347 | 319 | return BUF_SUCCESS; |
|---|
| 348 | | - |
|---|
| 349 | 320 | exit: |
|---|
| 350 | 321 | ebc_buf_uninit(); |
|---|
| 351 | | - buf_list_uninit(ebc_buf_info.osd_buf_list); |
|---|
| 352 | | -osd_list_err: |
|---|
| 353 | 322 | buf_list_uninit(ebc_buf_info.dsp_buf_list); |
|---|
| 354 | | -dsp_list_err: |
|---|
| 323 | +buf_list_err: |
|---|
| 355 | 324 | buf_list_uninit(ebc_buf_info.buf_list); |
|---|
| 356 | 325 | |
|---|
| 357 | 326 | return res; |
|---|