Ajay Singh Parmar | 7744a1d | 2016-05-16 17:58:33 -0700 | [diff] [blame] | 1 | /* |
Jeykumar Sankaran | 446a5f1 | 2017-05-09 20:30:39 -0700 | [diff] [blame] | 2 | * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved. |
Ajay Singh Parmar | 7744a1d | 2016-05-16 17:58:33 -0700 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 and |
| 6 | * only version 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #include <linux/delay.h> |
| 16 | #include <linux/slab.h> |
| 17 | |
| 18 | #include "dsi_display_test.h" |
| 19 | |
| 20 | static void dsi_display_test_dump_modes(struct dsi_display_mode *mode, u32 |
| 21 | count) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | static void dsi_display_test_work(struct work_struct *work) |
| 26 | { |
| 27 | struct dsi_display_test *test; |
| 28 | struct dsi_display *display; |
| 29 | struct dsi_display_mode *modes; |
| 30 | u32 count = 0; |
Ajay Singh Parmar | 7744a1d | 2016-05-16 17:58:33 -0700 | [diff] [blame] | 31 | int rc = 0; |
| 32 | |
| 33 | test = container_of(work, struct dsi_display_test, test_work); |
| 34 | |
| 35 | display = test->display; |
Jeykumar Sankaran | 446a5f1 | 2017-05-09 20:30:39 -0700 | [diff] [blame] | 36 | rc = dsi_display_get_mode_count(display, &count); |
Ajay Singh Parmar | 7744a1d | 2016-05-16 17:58:33 -0700 | [diff] [blame] | 37 | if (rc) { |
| 38 | pr_err("failed to get modes count, rc=%d\n", rc); |
| 39 | goto test_fail; |
| 40 | } |
| 41 | |
Lloyd Atkinson | 560785e | 2017-11-16 14:04:15 -0500 | [diff] [blame] | 42 | rc = dsi_display_get_modes(display, &modes); |
Ajay Singh Parmar | 7744a1d | 2016-05-16 17:58:33 -0700 | [diff] [blame] | 43 | if (rc) { |
| 44 | pr_err("failed to get modes, rc=%d\n", rc); |
| 45 | goto test_fail_free_modes; |
| 46 | } |
| 47 | |
| 48 | dsi_display_test_dump_modes(modes, count); |
| 49 | |
| 50 | rc = dsi_display_set_mode(display, &modes[0], 0x0); |
| 51 | if (rc) { |
| 52 | pr_err("failed to set mode, rc=%d\n", rc); |
| 53 | goto test_fail_free_modes; |
| 54 | } |
| 55 | |
| 56 | rc = dsi_display_prepare(display); |
| 57 | if (rc) { |
| 58 | pr_err("failed to prepare display, rc=%d\n", rc); |
| 59 | goto test_fail_free_modes; |
| 60 | } |
| 61 | |
| 62 | rc = dsi_display_enable(display); |
| 63 | if (rc) { |
| 64 | pr_err("failed to enable display, rc=%d\n", rc); |
| 65 | goto test_fail_unprep_disp; |
| 66 | } |
| 67 | return; |
| 68 | |
| 69 | test_fail_unprep_disp: |
| 70 | if (rc) { |
| 71 | pr_err("failed to unprep display, rc=%d\n", rc); |
| 72 | goto test_fail_free_modes; |
| 73 | } |
| 74 | |
| 75 | test_fail_free_modes: |
| 76 | kfree(modes); |
| 77 | test_fail: |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | int dsi_display_test_init(struct dsi_display *display) |
| 82 | { |
| 83 | static int done; |
| 84 | int rc = 0; |
| 85 | struct dsi_display_test *test; |
| 86 | |
| 87 | if (done) |
| 88 | return rc; |
| 89 | |
| 90 | done = 1; |
| 91 | if (!display) { |
| 92 | pr_err("Invalid params\n"); |
| 93 | return -EINVAL; |
| 94 | } |
| 95 | |
| 96 | test = kzalloc(sizeof(*test), GFP_KERNEL); |
| 97 | if (!test) |
| 98 | return -ENOMEM; |
| 99 | |
| 100 | test->display = display; |
| 101 | INIT_WORK(&test->test_work, dsi_display_test_work); |
| 102 | |
| 103 | dsi_display_test_work(&test->test_work); |
| 104 | return rc; |
| 105 | } |
| 106 | |