@@ -35,6 +35,13 @@ struct dptxport_apcall_lane_count {
3535 u8 _unk1 [8 ];
3636} __attribute__((packed ));
3737
38+ struct dptxport_apcall_set_active_lane_count {
39+ __le32 retcode ;
40+ u8 _unk0 [12 ];
41+ __le64 lane_count ;
42+ u8 _unk1 [8 ];
43+ } __packed ;
44+
3845struct dptxport_apcall_get_support {
3946 __le32 retcode ;
4047 u8 _unk0 [12 ];
@@ -178,6 +185,51 @@ static int dptxport_call_get_max_lane_count(struct apple_epic_service *service,
178185 return 0 ;
179186}
180187
188+ static int dptxport_call_set_active_lane_count (struct apple_epic_service * service ,
189+ const void * data , size_t data_size ,
190+ void * reply_ , size_t reply_size )
191+ {
192+ struct dptx_port * dptx = service -> cookie ;
193+ const struct dptxport_apcall_set_active_lane_count * request = data ;
194+ struct dptxport_apcall_set_active_lane_count * reply = reply_ ;
195+ int ret = 0 ;
196+ int retcode = 0 ;
197+
198+ if (reply_size < sizeof (* reply ))
199+ return -1 ;
200+ if (data_size < sizeof (* request ))
201+ return -1 ;
202+
203+ u64 lane_count = cpu_to_le64 (request -> lane_count );
204+
205+ switch (lane_count ) {
206+ case 0 ... 2 :
207+ case 4 :
208+ dptx -> phy_ops .dp .lanes = lane_count ;
209+ dptx -> phy_ops .dp .set_lanes = 1 ;
210+ break ;
211+ default :
212+ dev_err (service -> ep -> dcp -> dev , "set_active_lane_count: invalid lane count:%llu\n" , lane_count );
213+ retcode = 1 ;
214+ lane_count = 0 ;
215+ break ;
216+ }
217+
218+ if (dptx -> phy_ops .dp .set_lanes ) {
219+ if (dptx -> atcphy ) {
220+ ret = phy_configure (dptx -> atcphy , & dptx -> phy_ops );
221+ if (ret )
222+ return ret ;
223+ }
224+ dptx -> phy_ops .dp .set_lanes = 0 ;
225+ }
226+
227+ reply -> retcode = cpu_to_le32 (retcode );
228+ reply -> lane_count = cpu_to_le64 (lane_count );
229+
230+ return ret ;
231+ }
232+
181233static int dptxport_call_get_link_rate (struct apple_epic_service * service ,
182234 void * reply_ , size_t reply_size )
183235{
@@ -333,6 +385,9 @@ static int dptxport_call(struct apple_epic_service *service, u32 idx,
333385 reply , reply_size );
334386 case DPTX_APCALL_GET_MAX_LANE_COUNT :
335387 return dptxport_call_get_max_lane_count (service , reply , reply_size );
388+ case DPTX_APCALL_SET_ACTIVE_LANE_COUNT :
389+ return dptxport_call_set_active_lane_count (service , data , data_size ,
390+ reply , reply_size );
336391 case DPTX_APCALL_GET_SUPPORTS_HPD :
337392 return dptxport_call_get_supports_hpd (service , reply ,
338393 reply_size );
0 commit comments