diff options
author | Ruicheng Dai <rdai@nvidia.com> | 2017-09-04 23:09:02 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-10-10 11:05:17 -0400 |
commit | ee3820038a75ed962ea56a37501a19574b14b5ea (patch) | |
tree | 9d59c79d776231ded20fea51955e9fd5041bdb36 /drivers/media | |
parent | 0a201873113745162c0057e4f006782de133f2f8 (diff) |
media: tegra: nvcsi: csi5: send message to RCE
send IVC message to RCE to setup TPG
Bug 1947542
Change-Id: Ife6504350472e447c2adabe986f039b79d95a820
Signed-off-by: Ruicheng Dai <rdai@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1552013
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Shiva Dubey <sdubey@nvidia.com>
Reviewed-by: Pekka Pessi <ppessi@nvidia.com>
Reviewed-by: Jihoon Bang <jbang@nvidia.com>
GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/platform/tegra/camera/nvcsi/csi5_fops.c | 99 |
1 files changed, 98 insertions, 1 deletions
diff --git a/drivers/media/platform/tegra/camera/nvcsi/csi5_fops.c b/drivers/media/platform/tegra/camera/nvcsi/csi5_fops.c index 02c3c295e..727ef3006 100644 --- a/drivers/media/platform/tegra/camera/nvcsi/csi5_fops.c +++ b/drivers/media/platform/tegra/camera/nvcsi/csi5_fops.c | |||
@@ -14,6 +14,20 @@ | |||
14 | #include "nvhost_acm.h" | 14 | #include "nvhost_acm.h" |
15 | #include "nvcsi/nvcsi.h" | 15 | #include "nvcsi/nvcsi.h" |
16 | #include "csi5_fops.h" | 16 | #include "csi5_fops.h" |
17 | #include <linux/tegra-capture-ivc.h> | ||
18 | #include "soc/tegra/camrtc-capture-messages.h" | ||
19 | |||
20 | /* Referred from capture-scheduler.c defined in rtcpu-fw */ | ||
21 | #define NUM_CAPTURE_CHANNELS 64 | ||
22 | |||
23 | /* Temporary ids for the clients whose channel-id is not yet allocated */ | ||
24 | #define NUM_CAPTURE_TRANSACTION_IDS 64 | ||
25 | |||
26 | #define TOTAL_CHANNELS (NUM_CAPTURE_CHANNELS + NUM_CAPTURE_TRANSACTION_IDS) | ||
27 | |||
28 | #define TEMP_CHANNEL_ID (NUM_CAPTURE_CHANNELS + 1) | ||
29 | #define TPG_HBLANK 0 | ||
30 | #define TPG_VBLANK 40800 | ||
17 | 31 | ||
18 | static int csi5_power_on(struct tegra_csi_device *csi) | 32 | static int csi5_power_on(struct tegra_csi_device *csi) |
19 | { | 33 | { |
@@ -41,18 +55,101 @@ static int csi5_start_streaming(struct tegra_csi_channel *chan, | |||
41 | enum tegra_csi_port_num port_num) | 55 | enum tegra_csi_port_num port_num) |
42 | { | 56 | { |
43 | struct tegra_csi_device *csi = chan->csi; | 57 | struct tegra_csi_device *csi = chan->csi; |
58 | struct tegra_csi_port *port = &chan->ports[port_num]; | ||
59 | int err = 0; | ||
60 | |||
61 | /* PG native resolution */ | ||
62 | const size_t px_max = 0x4000; | ||
63 | const size_t py_max = 0x2000; | ||
64 | size_t hfreq = 0; | ||
65 | size_t vfreq = 0; | ||
66 | |||
67 | union nvcsi_tpg_config *pgc = NULL; | ||
68 | struct CAPTURE_CONTROL_MSG msg; | ||
69 | const size_t messageSize = sizeof(msg); | ||
44 | 70 | ||
71 | memset(&msg, 0, messageSize); | ||
45 | dev_info(csi->dev, "csi5_start_streaming\n"); | 72 | dev_info(csi->dev, "csi5_start_streaming\n"); |
73 | if (chan->pg_mode) { | ||
74 | pgc = &msg.tpg_setup_req.tpg_config; | ||
75 | |||
76 | hfreq = px_max / port->format.width; | ||
77 | vfreq = py_max / port->format.height; | ||
78 | |||
79 | pgc->t194.virtual_channel = 0; | ||
80 | /* hardcode CSI_DT_RAW_16 */ | ||
81 | pgc->t194.data_type = 46; | ||
82 | pgc->t194.lane_count = chan->numlanes; | ||
83 | pgc->t194.flags = NVCSI_TPG_FLAG_PATCH_MODE; | ||
84 | |||
85 | pgc->t194.initial_frame_number = 1; | ||
86 | pgc->t194.maximum_frame_number = 32768; | ||
87 | pgc->t194.image_width = port->format.width; | ||
88 | pgc->t194.image_height = port->format.height; | ||
89 | |||
90 | pgc->t194.red_horizontal_init_freq = hfreq; | ||
91 | pgc->t194.red_vertical_init_freq = vfreq; | ||
92 | |||
93 | pgc->t194.green_horizontal_init_freq = hfreq; | ||
94 | pgc->t194.green_vertical_init_freq = vfreq; | ||
95 | |||
96 | pgc->t194.blue_horizontal_init_freq = hfreq; | ||
97 | pgc->t194.blue_vertical_init_freq = vfreq; | ||
98 | |||
99 | msg.header.msg_id = CAPTURE_CHANNEL_TPG_SETUP_REQ; | ||
100 | /* use a free channel to send control */ | ||
101 | msg.header.channel_id = TEMP_CHANNEL_ID; | ||
102 | |||
103 | err = tegra_capture_ivc_control_submit(&msg, messageSize); | ||
104 | if (err < 0) { | ||
105 | dev_err(csi->dev, "IVC control submit failed\n"); | ||
106 | return err; | ||
107 | } | ||
108 | |||
109 | /* start streaming */ | ||
110 | memset(&msg, 0, messageSize); | ||
111 | msg.header.msg_id = CAPTURE_CHANNEL_TPG_START_REQ; | ||
112 | msg.header.channel_id = TEMP_CHANNEL_ID; | ||
113 | msg.tpg_start_req.stream = chan->port[0]; | ||
114 | msg.tpg_start_req.channel = 0; | ||
115 | msg.tpg_start_req.tpg_rate_config.hblank = TPG_HBLANK; | ||
116 | msg.tpg_start_req.tpg_rate_config.vblank = TPG_VBLANK; | ||
117 | msg.tpg_start_req.tpg_rate_config.pixel_interval = 0; | ||
118 | err = tegra_capture_ivc_control_submit(&msg, messageSize); | ||
119 | if (err < 0) { | ||
120 | dev_err(csi->dev, "IVC control submit failed\n"); | ||
121 | return err; | ||
122 | } | ||
123 | } | ||
46 | 124 | ||
47 | return 0; | 125 | return err; |
48 | } | 126 | } |
49 | 127 | ||
50 | static void csi5_stop_streaming(struct tegra_csi_channel *chan, | 128 | static void csi5_stop_streaming(struct tegra_csi_channel *chan, |
51 | enum tegra_csi_port_num port_num) | 129 | enum tegra_csi_port_num port_num) |
52 | { | 130 | { |
53 | struct tegra_csi_device *csi = chan->csi; | 131 | struct tegra_csi_device *csi = chan->csi; |
132 | int err = 0; | ||
133 | |||
134 | struct CAPTURE_CONTROL_MSG msg; | ||
135 | const size_t messageSize = sizeof(msg); | ||
54 | 136 | ||
137 | memset(&msg, 0, messageSize); | ||
55 | dev_info(csi->dev, "csi5_stop_streaming\n"); | 138 | dev_info(csi->dev, "csi5_stop_streaming\n"); |
139 | |||
140 | if (chan->pg_mode) { | ||
141 | msg.header.msg_id = CAPTURE_CHANNEL_TPG_STOP_REQ; | ||
142 | msg.header.channel_id = TEMP_CHANNEL_ID; | ||
143 | |||
144 | msg.tpg_stop_req.stream = chan->port[0]; | ||
145 | msg.tpg_stop_req.channel = 0; | ||
146 | |||
147 | err = tegra_capture_ivc_control_submit(&msg, messageSize); | ||
148 | if (err < 0) { | ||
149 | dev_err(csi->dev, "IVC control submit failed\n"); | ||
150 | return; | ||
151 | } | ||
152 | } | ||
56 | } | 153 | } |
57 | 154 | ||
58 | static int csi5_mipi_cal(struct tegra_csi_channel *chan) | 155 | static int csi5_mipi_cal(struct tegra_csi_channel *chan) |