18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * vivid-touch-cap.c - touch support functions. 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#include "vivid-core.h" 78c2ecf20Sopenharmony_ci#include "vivid-kthread-touch.h" 88c2ecf20Sopenharmony_ci#include "vivid-vid-common.h" 98c2ecf20Sopenharmony_ci#include "vivid-touch-cap.h" 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistatic int touch_cap_queue_setup(struct vb2_queue *vq, unsigned int *nbuffers, 128c2ecf20Sopenharmony_ci unsigned int *nplanes, unsigned int sizes[], 138c2ecf20Sopenharmony_ci struct device *alloc_devs[]) 148c2ecf20Sopenharmony_ci{ 158c2ecf20Sopenharmony_ci struct vivid_dev *dev = vb2_get_drv_priv(vq); 168c2ecf20Sopenharmony_ci struct v4l2_pix_format *f = &dev->tch_format; 178c2ecf20Sopenharmony_ci unsigned int size = f->sizeimage; 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci if (*nplanes) { 208c2ecf20Sopenharmony_ci if (sizes[0] < size) 218c2ecf20Sopenharmony_ci return -EINVAL; 228c2ecf20Sopenharmony_ci } else { 238c2ecf20Sopenharmony_ci sizes[0] = size; 248c2ecf20Sopenharmony_ci } 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci if (vq->num_buffers + *nbuffers < 2) 278c2ecf20Sopenharmony_ci *nbuffers = 2 - vq->num_buffers; 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_ci *nplanes = 1; 308c2ecf20Sopenharmony_ci return 0; 318c2ecf20Sopenharmony_ci} 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_cistatic int touch_cap_buf_prepare(struct vb2_buffer *vb) 348c2ecf20Sopenharmony_ci{ 358c2ecf20Sopenharmony_ci struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); 368c2ecf20Sopenharmony_ci struct v4l2_pix_format *f = &dev->tch_format; 378c2ecf20Sopenharmony_ci unsigned int size = f->sizeimage; 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci if (dev->buf_prepare_error) { 408c2ecf20Sopenharmony_ci /* 418c2ecf20Sopenharmony_ci * Error injection: test what happens if buf_prepare() returns 428c2ecf20Sopenharmony_ci * an error. 438c2ecf20Sopenharmony_ci */ 448c2ecf20Sopenharmony_ci dev->buf_prepare_error = false; 458c2ecf20Sopenharmony_ci return -EINVAL; 468c2ecf20Sopenharmony_ci } 478c2ecf20Sopenharmony_ci if (vb2_plane_size(vb, 0) < size) { 488c2ecf20Sopenharmony_ci dprintk(dev, 1, "%s data will not fit into plane (%lu < %u)\n", 498c2ecf20Sopenharmony_ci __func__, vb2_plane_size(vb, 0), size); 508c2ecf20Sopenharmony_ci return -EINVAL; 518c2ecf20Sopenharmony_ci } 528c2ecf20Sopenharmony_ci vb2_set_plane_payload(vb, 0, size); 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci return 0; 558c2ecf20Sopenharmony_ci} 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_cistatic void touch_cap_buf_queue(struct vb2_buffer *vb) 588c2ecf20Sopenharmony_ci{ 598c2ecf20Sopenharmony_ci struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb); 608c2ecf20Sopenharmony_ci struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); 618c2ecf20Sopenharmony_ci struct vivid_buffer *buf = container_of(vbuf, struct vivid_buffer, vb); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci vbuf->field = V4L2_FIELD_NONE; 648c2ecf20Sopenharmony_ci spin_lock(&dev->slock); 658c2ecf20Sopenharmony_ci list_add_tail(&buf->list, &dev->touch_cap_active); 668c2ecf20Sopenharmony_ci spin_unlock(&dev->slock); 678c2ecf20Sopenharmony_ci} 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_cistatic int touch_cap_start_streaming(struct vb2_queue *vq, unsigned int count) 708c2ecf20Sopenharmony_ci{ 718c2ecf20Sopenharmony_ci struct vivid_dev *dev = vb2_get_drv_priv(vq); 728c2ecf20Sopenharmony_ci int err; 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci dev->touch_cap_seq_count = 0; 758c2ecf20Sopenharmony_ci if (dev->start_streaming_error) { 768c2ecf20Sopenharmony_ci dev->start_streaming_error = false; 778c2ecf20Sopenharmony_ci err = -EINVAL; 788c2ecf20Sopenharmony_ci } else { 798c2ecf20Sopenharmony_ci err = vivid_start_generating_touch_cap(dev); 808c2ecf20Sopenharmony_ci } 818c2ecf20Sopenharmony_ci if (err) { 828c2ecf20Sopenharmony_ci struct vivid_buffer *buf, *tmp; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_ci list_for_each_entry_safe(buf, tmp, 858c2ecf20Sopenharmony_ci &dev->touch_cap_active, list) { 868c2ecf20Sopenharmony_ci list_del(&buf->list); 878c2ecf20Sopenharmony_ci vb2_buffer_done(&buf->vb.vb2_buf, 888c2ecf20Sopenharmony_ci VB2_BUF_STATE_QUEUED); 898c2ecf20Sopenharmony_ci } 908c2ecf20Sopenharmony_ci } 918c2ecf20Sopenharmony_ci return err; 928c2ecf20Sopenharmony_ci} 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci/* abort streaming and wait for last buffer */ 958c2ecf20Sopenharmony_cistatic void touch_cap_stop_streaming(struct vb2_queue *vq) 968c2ecf20Sopenharmony_ci{ 978c2ecf20Sopenharmony_ci struct vivid_dev *dev = vb2_get_drv_priv(vq); 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci vivid_stop_generating_touch_cap(dev); 1008c2ecf20Sopenharmony_ci} 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_cistatic void touch_cap_buf_request_complete(struct vb2_buffer *vb) 1038c2ecf20Sopenharmony_ci{ 1048c2ecf20Sopenharmony_ci struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ci v4l2_ctrl_request_complete(vb->req_obj.req, &dev->ctrl_hdl_touch_cap); 1078c2ecf20Sopenharmony_ci} 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ciconst struct vb2_ops vivid_touch_cap_qops = { 1108c2ecf20Sopenharmony_ci .queue_setup = touch_cap_queue_setup, 1118c2ecf20Sopenharmony_ci .buf_prepare = touch_cap_buf_prepare, 1128c2ecf20Sopenharmony_ci .buf_queue = touch_cap_buf_queue, 1138c2ecf20Sopenharmony_ci .start_streaming = touch_cap_start_streaming, 1148c2ecf20Sopenharmony_ci .stop_streaming = touch_cap_stop_streaming, 1158c2ecf20Sopenharmony_ci .buf_request_complete = touch_cap_buf_request_complete, 1168c2ecf20Sopenharmony_ci .wait_prepare = vb2_ops_wait_prepare, 1178c2ecf20Sopenharmony_ci .wait_finish = vb2_ops_wait_finish, 1188c2ecf20Sopenharmony_ci}; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ciint vivid_enum_fmt_tch(struct file *file, void *priv, struct v4l2_fmtdesc *f) 1218c2ecf20Sopenharmony_ci{ 1228c2ecf20Sopenharmony_ci if (f->index) 1238c2ecf20Sopenharmony_ci return -EINVAL; 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci f->pixelformat = V4L2_TCH_FMT_DELTA_TD16; 1268c2ecf20Sopenharmony_ci return 0; 1278c2ecf20Sopenharmony_ci} 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ciint vivid_g_fmt_tch(struct file *file, void *priv, struct v4l2_format *f) 1308c2ecf20Sopenharmony_ci{ 1318c2ecf20Sopenharmony_ci struct vivid_dev *dev = video_drvdata(file); 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci if (dev->multiplanar) 1348c2ecf20Sopenharmony_ci return -ENOTTY; 1358c2ecf20Sopenharmony_ci f->fmt.pix = dev->tch_format; 1368c2ecf20Sopenharmony_ci return 0; 1378c2ecf20Sopenharmony_ci} 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ciint vivid_g_fmt_tch_mplane(struct file *file, void *priv, struct v4l2_format *f) 1408c2ecf20Sopenharmony_ci{ 1418c2ecf20Sopenharmony_ci struct vivid_dev *dev = video_drvdata(file); 1428c2ecf20Sopenharmony_ci struct v4l2_format sp_fmt; 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci if (!dev->multiplanar) 1458c2ecf20Sopenharmony_ci return -ENOTTY; 1468c2ecf20Sopenharmony_ci sp_fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1478c2ecf20Sopenharmony_ci sp_fmt.fmt.pix = dev->tch_format; 1488c2ecf20Sopenharmony_ci fmt_sp2mp(&sp_fmt, f); 1498c2ecf20Sopenharmony_ci return 0; 1508c2ecf20Sopenharmony_ci} 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_ciint vivid_g_parm_tch(struct file *file, void *priv, 1538c2ecf20Sopenharmony_ci struct v4l2_streamparm *parm) 1548c2ecf20Sopenharmony_ci{ 1558c2ecf20Sopenharmony_ci struct vivid_dev *dev = video_drvdata(file); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci if (parm->type != (dev->multiplanar ? 1588c2ecf20Sopenharmony_ci V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE : 1598c2ecf20Sopenharmony_ci V4L2_BUF_TYPE_VIDEO_CAPTURE)) 1608c2ecf20Sopenharmony_ci return -EINVAL; 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci parm->parm.capture.capability = V4L2_CAP_TIMEPERFRAME; 1638c2ecf20Sopenharmony_ci parm->parm.capture.timeperframe = dev->timeperframe_tch_cap; 1648c2ecf20Sopenharmony_ci parm->parm.capture.readbuffers = 1; 1658c2ecf20Sopenharmony_ci return 0; 1668c2ecf20Sopenharmony_ci} 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ciint vivid_enum_input_tch(struct file *file, void *priv, struct v4l2_input *inp) 1698c2ecf20Sopenharmony_ci{ 1708c2ecf20Sopenharmony_ci if (inp->index) 1718c2ecf20Sopenharmony_ci return -EINVAL; 1728c2ecf20Sopenharmony_ci 1738c2ecf20Sopenharmony_ci inp->type = V4L2_INPUT_TYPE_TOUCH; 1748c2ecf20Sopenharmony_ci strscpy(inp->name, "Vivid Touch", sizeof(inp->name)); 1758c2ecf20Sopenharmony_ci inp->capabilities = 0; 1768c2ecf20Sopenharmony_ci return 0; 1778c2ecf20Sopenharmony_ci} 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ciint vivid_g_input_tch(struct file *file, void *priv, unsigned int *i) 1808c2ecf20Sopenharmony_ci{ 1818c2ecf20Sopenharmony_ci *i = 0; 1828c2ecf20Sopenharmony_ci return 0; 1838c2ecf20Sopenharmony_ci} 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ciint vivid_set_touch(struct vivid_dev *dev, unsigned int i) 1868c2ecf20Sopenharmony_ci{ 1878c2ecf20Sopenharmony_ci struct v4l2_pix_format *f = &dev->tch_format; 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci if (i) 1908c2ecf20Sopenharmony_ci return -EINVAL; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci f->pixelformat = V4L2_TCH_FMT_DELTA_TD16; 1938c2ecf20Sopenharmony_ci f->width = VIVID_TCH_WIDTH; 1948c2ecf20Sopenharmony_ci f->height = VIVID_TCH_HEIGHT; 1958c2ecf20Sopenharmony_ci f->field = V4L2_FIELD_NONE; 1968c2ecf20Sopenharmony_ci f->colorspace = V4L2_COLORSPACE_RAW; 1978c2ecf20Sopenharmony_ci f->bytesperline = f->width * sizeof(s16); 1988c2ecf20Sopenharmony_ci f->sizeimage = f->width * f->height * sizeof(s16); 1998c2ecf20Sopenharmony_ci return 0; 2008c2ecf20Sopenharmony_ci} 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ciint vivid_s_input_tch(struct file *file, void *priv, unsigned int i) 2038c2ecf20Sopenharmony_ci{ 2048c2ecf20Sopenharmony_ci return vivid_set_touch(video_drvdata(file), i); 2058c2ecf20Sopenharmony_ci} 2068c2ecf20Sopenharmony_ci 2078c2ecf20Sopenharmony_cistatic void vivid_fill_buff_noise(__s16 *tch_buf, int size) 2088c2ecf20Sopenharmony_ci{ 2098c2ecf20Sopenharmony_ci int i; 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci /* Fill 10% of the values within range -3 and 3, zero the others */ 2128c2ecf20Sopenharmony_ci for (i = 0; i < size; i++) { 2138c2ecf20Sopenharmony_ci unsigned int rand = get_random_int(); 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci if (rand % 10) 2168c2ecf20Sopenharmony_ci tch_buf[i] = 0; 2178c2ecf20Sopenharmony_ci else 2188c2ecf20Sopenharmony_ci tch_buf[i] = (rand / 10) % 7 - 3; 2198c2ecf20Sopenharmony_ci } 2208c2ecf20Sopenharmony_ci} 2218c2ecf20Sopenharmony_ci 2228c2ecf20Sopenharmony_cistatic inline int get_random_pressure(void) 2238c2ecf20Sopenharmony_ci{ 2248c2ecf20Sopenharmony_ci return get_random_int() % VIVID_PRESSURE_LIMIT; 2258c2ecf20Sopenharmony_ci} 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_cistatic void vivid_tch_buf_set(struct v4l2_pix_format *f, 2288c2ecf20Sopenharmony_ci __s16 *tch_buf, 2298c2ecf20Sopenharmony_ci int index) 2308c2ecf20Sopenharmony_ci{ 2318c2ecf20Sopenharmony_ci unsigned int x = index % f->width; 2328c2ecf20Sopenharmony_ci unsigned int y = index / f->width; 2338c2ecf20Sopenharmony_ci unsigned int offset = VIVID_MIN_PRESSURE; 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci tch_buf[index] = offset + get_random_pressure(); 2368c2ecf20Sopenharmony_ci offset /= 2; 2378c2ecf20Sopenharmony_ci if (x) 2388c2ecf20Sopenharmony_ci tch_buf[index - 1] = offset + get_random_pressure(); 2398c2ecf20Sopenharmony_ci if (x < f->width - 1) 2408c2ecf20Sopenharmony_ci tch_buf[index + 1] = offset + get_random_pressure(); 2418c2ecf20Sopenharmony_ci if (y) 2428c2ecf20Sopenharmony_ci tch_buf[index - f->width] = offset + get_random_pressure(); 2438c2ecf20Sopenharmony_ci if (y < f->height - 1) 2448c2ecf20Sopenharmony_ci tch_buf[index + f->width] = offset + get_random_pressure(); 2458c2ecf20Sopenharmony_ci offset /= 2; 2468c2ecf20Sopenharmony_ci if (x && y) 2478c2ecf20Sopenharmony_ci tch_buf[index - 1 - f->width] = offset + get_random_pressure(); 2488c2ecf20Sopenharmony_ci if (x < f->width - 1 && y) 2498c2ecf20Sopenharmony_ci tch_buf[index + 1 - f->width] = offset + get_random_pressure(); 2508c2ecf20Sopenharmony_ci if (x && y < f->height - 1) 2518c2ecf20Sopenharmony_ci tch_buf[index - 1 + f->width] = offset + get_random_pressure(); 2528c2ecf20Sopenharmony_ci if (x < f->width - 1 && y < f->height - 1) 2538c2ecf20Sopenharmony_ci tch_buf[index + 1 + f->width] = offset + get_random_pressure(); 2548c2ecf20Sopenharmony_ci} 2558c2ecf20Sopenharmony_ci 2568c2ecf20Sopenharmony_civoid vivid_fillbuff_tch(struct vivid_dev *dev, struct vivid_buffer *buf) 2578c2ecf20Sopenharmony_ci{ 2588c2ecf20Sopenharmony_ci struct v4l2_pix_format *f = &dev->tch_format; 2598c2ecf20Sopenharmony_ci int size = f->width * f->height; 2608c2ecf20Sopenharmony_ci int x, y, xstart, ystart, offset_x, offset_y; 2618c2ecf20Sopenharmony_ci unsigned int test_pattern, test_pat_idx, rand; 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci __s16 *tch_buf = vb2_plane_vaddr(&buf->vb.vb2_buf, 0); 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci buf->vb.sequence = dev->touch_cap_seq_count; 2668c2ecf20Sopenharmony_ci test_pattern = (buf->vb.sequence / TCH_SEQ_COUNT) % TEST_CASE_MAX; 2678c2ecf20Sopenharmony_ci test_pat_idx = buf->vb.sequence % TCH_SEQ_COUNT; 2688c2ecf20Sopenharmony_ci 2698c2ecf20Sopenharmony_ci vivid_fill_buff_noise(tch_buf, size); 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci if (test_pat_idx >= TCH_PATTERN_COUNT) 2728c2ecf20Sopenharmony_ci return; 2738c2ecf20Sopenharmony_ci 2748c2ecf20Sopenharmony_ci if (test_pat_idx == 0) 2758c2ecf20Sopenharmony_ci dev->tch_pat_random = get_random_int(); 2768c2ecf20Sopenharmony_ci rand = dev->tch_pat_random; 2778c2ecf20Sopenharmony_ci 2788c2ecf20Sopenharmony_ci switch (test_pattern) { 2798c2ecf20Sopenharmony_ci case SINGLE_TAP: 2808c2ecf20Sopenharmony_ci if (test_pat_idx == 2) 2818c2ecf20Sopenharmony_ci vivid_tch_buf_set(f, tch_buf, rand % size); 2828c2ecf20Sopenharmony_ci break; 2838c2ecf20Sopenharmony_ci case DOUBLE_TAP: 2848c2ecf20Sopenharmony_ci if (test_pat_idx == 2 || test_pat_idx == 4) 2858c2ecf20Sopenharmony_ci vivid_tch_buf_set(f, tch_buf, rand % size); 2868c2ecf20Sopenharmony_ci break; 2878c2ecf20Sopenharmony_ci case TRIPLE_TAP: 2888c2ecf20Sopenharmony_ci if (test_pat_idx == 2 || test_pat_idx == 4 || test_pat_idx == 6) 2898c2ecf20Sopenharmony_ci vivid_tch_buf_set(f, tch_buf, rand % size); 2908c2ecf20Sopenharmony_ci break; 2918c2ecf20Sopenharmony_ci case MOVE_LEFT_TO_RIGHT: 2928c2ecf20Sopenharmony_ci vivid_tch_buf_set(f, tch_buf, 2938c2ecf20Sopenharmony_ci (rand % f->height) * f->width + 2948c2ecf20Sopenharmony_ci test_pat_idx * 2958c2ecf20Sopenharmony_ci (f->width / TCH_PATTERN_COUNT)); 2968c2ecf20Sopenharmony_ci break; 2978c2ecf20Sopenharmony_ci case ZOOM_IN: 2988c2ecf20Sopenharmony_ci x = f->width / 2; 2998c2ecf20Sopenharmony_ci y = f->height / 2; 3008c2ecf20Sopenharmony_ci offset_x = ((TCH_PATTERN_COUNT - 1 - test_pat_idx) * x) / 3018c2ecf20Sopenharmony_ci TCH_PATTERN_COUNT; 3028c2ecf20Sopenharmony_ci offset_y = ((TCH_PATTERN_COUNT - 1 - test_pat_idx) * y) / 3038c2ecf20Sopenharmony_ci TCH_PATTERN_COUNT; 3048c2ecf20Sopenharmony_ci vivid_tch_buf_set(f, tch_buf, 3058c2ecf20Sopenharmony_ci (x - offset_x) + f->width * (y - offset_y)); 3068c2ecf20Sopenharmony_ci vivid_tch_buf_set(f, tch_buf, 3078c2ecf20Sopenharmony_ci (x + offset_x) + f->width * (y + offset_y)); 3088c2ecf20Sopenharmony_ci break; 3098c2ecf20Sopenharmony_ci case ZOOM_OUT: 3108c2ecf20Sopenharmony_ci x = f->width / 2; 3118c2ecf20Sopenharmony_ci y = f->height / 2; 3128c2ecf20Sopenharmony_ci offset_x = (test_pat_idx * x) / TCH_PATTERN_COUNT; 3138c2ecf20Sopenharmony_ci offset_y = (test_pat_idx * y) / TCH_PATTERN_COUNT; 3148c2ecf20Sopenharmony_ci vivid_tch_buf_set(f, tch_buf, 3158c2ecf20Sopenharmony_ci (x - offset_x) + f->width * (y - offset_y)); 3168c2ecf20Sopenharmony_ci vivid_tch_buf_set(f, tch_buf, 3178c2ecf20Sopenharmony_ci (x + offset_x) + f->width * (y + offset_y)); 3188c2ecf20Sopenharmony_ci break; 3198c2ecf20Sopenharmony_ci case PALM_PRESS: 3208c2ecf20Sopenharmony_ci for (x = 0; x < f->width; x++) 3218c2ecf20Sopenharmony_ci for (y = f->height / 2; y < f->height; y++) 3228c2ecf20Sopenharmony_ci tch_buf[x + f->width * y] = VIVID_MIN_PRESSURE + 3238c2ecf20Sopenharmony_ci get_random_pressure(); 3248c2ecf20Sopenharmony_ci break; 3258c2ecf20Sopenharmony_ci case MULTIPLE_PRESS: 3268c2ecf20Sopenharmony_ci /* 16 pressure points */ 3278c2ecf20Sopenharmony_ci for (y = 0; y < 4; y++) { 3288c2ecf20Sopenharmony_ci for (x = 0; x < 4; x++) { 3298c2ecf20Sopenharmony_ci ystart = (y * f->height) / 4 + f->height / 8; 3308c2ecf20Sopenharmony_ci xstart = (x * f->width) / 4 + f->width / 8; 3318c2ecf20Sopenharmony_ci vivid_tch_buf_set(f, tch_buf, 3328c2ecf20Sopenharmony_ci ystart * f->width + xstart); 3338c2ecf20Sopenharmony_ci } 3348c2ecf20Sopenharmony_ci } 3358c2ecf20Sopenharmony_ci break; 3368c2ecf20Sopenharmony_ci } 3378c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN__ 3388c2ecf20Sopenharmony_ci for (x = 0; x < size; x++) 3398c2ecf20Sopenharmony_ci tch_buf[x] = (__force s16)__cpu_to_le16((u16)tch_buf[x]); 3408c2ecf20Sopenharmony_ci#endif 3418c2ecf20Sopenharmony_ci} 342