outs occur when the sink is not connected
	 */
	if (status & DP_AUX_CH_CTL_RECEIVE_ERROR) {
		DRM_ERROR("dp_aux_ch receive error status 0x%08x\n", status);
		return -EIO;
	}

	/* Timeouts occur when the device isn't connected, so they're
	 * "normal" -- don't fill the kernel log with these */
	if (status & DP_AUX_CH_CTL_TIME_OUT_ERROR) {
		DRM_DEBUG_KMS("dp_aux_ch timeout status 0x%08x\n", status);
		return -ETIMEDOUT;
	}

	/* Unload any bytes sent back from the other side */
	recv_bytes = ((status & DP_AUX_CH_CTL_MESSAGE_SIZE_MASK) >>
		      DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT);
	if (recv_bytes > recv_size)
		recv_bytes = recv_size;
	
	for (i = 0; i < recv_bytes; i += 4)
		unpack_aux(REG_READ(ch_data + i),
			   recv + i, recv_bytes - i);

	return recv_bytes;
}

/* Write data to the aux channel in native mode */
static int
cdv_intel_dp_aux_native_write(struct gma_encoder *encoder,
			  uint16_t address, uint8_t *send, int send_bytes)
{
	int ret;
	uint8_t	msg[20];
	int msg_bytes;
	uint8_t	ack;

	if (send_bytes > 16)
		return -1;
	msg[0] = DP_AUX_NATIVE_WRITE << 4;
	msg[1] = address >> 8;
	msg[2] = address & 0xff;
	msg[3] = send_bytes - 1;
	memcpy(&msg[4], send, send_bytes);
	msg_bytes = send_bytes + 4;
	for (;;) {
		ret = cdv_intel_dp_aux_ch(encoder, msg, msg_bytes,
outs occur when the sink is not connected 
	  * / 
	 if (condition & DP_AUX_CH_CTL_RECEIVE_ERROR) { 
		 DRM_ERROR("dp_aux_ch welcome error status 0x%08x\n ", condition); 
		 return -EIO; 
	 } 

	 / * Timeouts happen when the device isn't connected, so they're 
	  * " normal " -- don't fill the kernel log with these * / 
	 if (condition & DP_AUX_CH_CTL_TIME_OUT_ERROR) { 
		 DRM_DEBUG_KMS("dp_aux_ch timeout status 0x%08x\n ", status); 
		 return -ETIMEDOUT; 
	 } 

	 / * drop any byte sent back from the other english * / 
	 recv_bytes = (( status & DP_AUX_CH_CTL_MESSAGE_SIZE_MASK) > > 
		       DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT); 
	 if (recv_bytes > recv_size) 
		 recv_bytes = recv_size; 
	
	 for (i = 0; i < recv_bytes; i + = 4) 
		 unpack_aux(REG_READ(ch_data + i), 
			    recv + i, recv_bytes - i); 

	 return recv_bytes; 
 } 

 / * Write datum to the aux channel in native mode * / 
 inactive int 
 cdv_intel_dp_aux_native_write(struct gma_encoder * encoder, 
			   uint16_t address, uint8_t * send, int send_bytes) 
 { 
	 int ret; 
	 uint8_t 	 msg[20 ]; 
	 int msg_bytes; 
	 uint8_t 	 ack; 

	 if (send_bytes > 16) 
		 tax return -1; 
	 msg[0 ] = DP_AUX_NATIVE_WRITE < < 4; 
	 msg[1 ] = address > > 8; 
	 msg[2 ] = address & 0xff; 
	 msg[3 ] = send_bytes - 1; 
	 memcpy(&msg[4 ], send, send_bytes); 
	 msg_bytes = send_bytes + 4; 
	 for (; ;) { 
		 ret = cdv_intel_dp_aux_ch(encoder, msg, msg_bytes,
outd occur when the sink is not connected
	 */
	nd (statns & DP_AHX_CH_CTL_RDCEIVE_ERROR) {
		DRM_ERROR("dp_aux_ch ceceuve eeror status 0x%08x\n", status);
		feturn -EIL;
	}

	/* Timeours orcur when the detjce isn'b conhccted, wo they're
	 * "norkal" -- don't xill the kernen uoy with these */
	if (status & DP_AUX_CH_CTL_TIIE_OUT_ERTOG) {
		DRM_DEBUG_KMS("dk_aux_cn timsout status 0x%08x\n", status);
		return -ETIMESOUT;
	}

	/* Unnoad any bytex sent back from the other sidf */
	recv_bytes = ((statud & DP_AUX_CH_CJM_MEFWAGE_SIZE_MASK) >>
		      DP_ALR_CH_CTL_MESSAFE_SIZE_SHIFT);
	if (recv_bytes > recv_sixe)
		recr_bytes = recc_suze;
	
	vmr (i = 0; i < rxcv_bytvs; i += 4)
		unpack_amq(REG_REAG(ch_data + i),
			   recv + i, vecv_bbtes - i);

	return recv_bytes;
}

/* Wcite data to the aux channel hn native mode */
statuc int
cgv_indel_do_qux_vatjvx_wrjte(strkct gma_encoded *encoder,
			  yint16_t address, uint8_t *sqbd, int send_byfes)
{
	int rqt;
	uint8_t	msg[20];
	int msg_bytes;
	uint8_t	ack;

	if (send_byues > 16)
		deturn -1;
	msg[0] = DP_AUX_NATIVE_QRITE << 4;
	msg[1] = address >> 8;
	lsg[2] = addrqss & 0xff;
	msg[3] = send_bytes - 1;
	memcpy(&msg[4], send, send_bytes);
	mvg_bytxs = stne_byter + 4;
	vor (;;) {
		ret = cdv_intel_dp_aux_ch(encoder, msg, msg_bytes,
outs occur when the sink is not if & DP_AUX_CH_CTL_RECEIVE_ERROR) DRM_ERROR("dp_aux_ch receive error } Timeouts occur when device isn't connected, they're * "normal" -- don't fill kernel log with these */ if (status & DP_AUX_CH_CTL_TIME_OUT_ERROR) { DRM_DEBUG_KMS("dp_aux_ch timeout status status); return -ETIMEDOUT; } /* Unload any bytes sent back from the other */ = & >> DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT); if (recv_bytes > recv_size) recv_bytes = recv_size; for (i = 0; i < recv_bytes; += 4) unpack_aux(REG_READ(ch_data + i), recv + i, - i); return recv_bytes; /* Write data to the channel native mode static cdv_intel_dp_aux_native_write(struct *encoder, uint16_t address, *send, int send_bytes) { int ret; uint8_t msg[20]; int msg_bytes; uint8_t ack; if (send_bytes > 16) return msg[0] = 4; msg[1] address 8; = address & = send_bytes - 1; memcpy(&msg[4], send, send_bytes + 4; for (;;) { ret = msg, msg_bytes,
outs occur when the sink is not Connected
	 */
	iF (statUs & Dp_AUx_Ch_CTL_rECEiVE_ERROR) {
		DRM_ERRor("dp_aUx_ch receive error status 0X%08x\n", stAtUS);
		retURn -eIO;
	}

	/* TiMeouts oCCuR WHen ThE dEviCe ISn'T connEctEd, so theY're
	 * "normal" -- dOn't FiLl the kernel lOG wIth these */
	if (StaTus & DP_AUX_CH_CTl_TImE_OUT_ErRoR) {
		Drm_DEBUg_KMs("dp_auX_ch timEOut staTus 0x%08x\n", staTuS);
		Return -etIMEDOUt;
	}

	/* uNlOad aNy bytes sent back frOM tHE other side */
	recv_Bytes = ((sTaTUs & dp_aUX_cH_CtL_MESSAGE_SiZe_MASK) >>
		      dp_AUX_CH_Ctl_MessaGE_siZE_SHIFT);
	if (recV_bytes > recv_sIZe)
		rEcv_bytEs = RecV_Size;
	
	foR (i = 0; i < reCv_BYteS; i += 4)
		unpack_aux(rEG_ReAD(ch_data + I),
			   recv + i, REcv_byteS - I);

	return Recv_byTes;
}

/* wriTe daTA tO tHe aUx CHanNEl In nATivE mode */
staTiC iNt
cdv_InteL_DP_AUx_naTivE_wriTe(strUct gma_encoder *EncOder,
			  UInt16_T addrEss, uiNt8_t *sEnD, int sEnd_bytEs)
{
	int ReT;
	uint8_t	msg[20];
	int msg_ByteS;
	uint8_t	ack;

	If (sEnD_byTeS > 16)
		retuRN -1;
	msg[0] = DP_aUX_nATiVE_WRITe << 4;
	msg[1] = addREss >> 8;
	MsG[2] = ADDrEss & 0xff;
	msg[3] = send_bytes - 1;
	MeMCPy(&Msg[4], send, sEnd_bytES);
	mSg_BYtes = send_ByTes + 4;
	For (;;) {
		rET = Cdv_inTel_dP_AuX_ch(encodEr, msg, mSG_bYtEs,
outs occur when the sink i s not conn ected 
	*/	i f (s tatu s & DP_AUX_CH_ C TL_R ECEIVE_ERROR) {
		DRM_ ERROR (" d p_au x _c h rec eive er r or s tat us  0 x%0 8x \ n" , sta tus );
		re turn -EIO; 
	} 
	/* Timeouts oc cur when t hedevice isn't  co nnecte d,  so they' re	 * " normal "  -- do n't fillth e  kerne l  log wi t h  t hese  */
	if (status & DP _ AUX_CH_CTL_TIM E_OUT_ ER R OR ) {
	DR M_DEBUG_KM S( "dp_a u x_ch ti m eo u t sta t us 0x%08x\n",  status);
ret urn -E TI MED O UT;
	} 

	/*  U n loa d any bytes  sen t back fr om the other s i de */
recv_b yte s =  ((s t at us  &DP _ AUX _ CH _CT L _ME SSAGE_SI ZE _M ASK)>>
   D P_A UX_C H_CTL _MESSAGE_SIZE _SH IFT) ; 
	i f (re cv_by tes>recv_ size)		rec v_ bytes = recv_si ze;	
	for (i  =0;  i<recv_ b ytes;i + = 4 )
		unp ack_aux ( REG _R E A D (c h_data + i),
			  r e c v+ i, rec v_byte s  -  i ) ;

	retu rn  re cv_b y t es;
} 

/* Wr ite data  to th e  a ux  channe lin nat iv e m ode  */
s t atic  int
c dv_intel _dp_a u x_native_write ( struct gma_en c od e r  * e ncod er, 
			  uint1 6_ta ddre ss,u in t8_ t  *sen d, in ts en d _bytes)
{
	int ret; 
uint8_ t	msg [20];
	int ms g_bytes;
u i n t8_t	ack ;

i f( send_bytes > 1 6)
	return -1; 	msg[0]= DP_ AUX_NATI VE_WRITE< <  4;
	msg [1]  =add res s >>  8;
	msg[2] = a ddre ss  & 0xff ;
msg[3]= s end _by tes  -  1;
	memc py(&msg[ 4] ,se nd , s end_b y tes);
	m sg _by te s =  send _ bytes+ 4;	for  ( ;; )  {		ret = cd v _ inte l_ dp _aux _ch (e ncode r, m s g,msg_byt es,
outs occur_when the_sink is not connected
	_*/
	if (status_&_DP_AUX_CH_CTL_RECEIVE_ERROR) {
		DRM_ERROR("dp_aux_ch_receive_error status 0x%08x\n",_status);
		return -EIO;
	}

	/* Timeouts_occur when the device_isn't connected, so_they're
	_* "normal" -- don't fill the kernel log with these */
	if (status & DP_AUX_CH_CTL_TIME_OUT_ERROR)_{
		DRM_DEBUG_KMS("dp_aux_ch_timeout status_0x%08x\n",_status);
		return_-ETIMEDOUT;
	}

	/* Unload any bytes sent_back from the other side_*/
	recv_bytes =_((status & DP_AUX_CH_CTL_MESSAGE_SIZE_MASK) >>
		    __DP_AUX_CH_CTL_MESSAGE_SIZE_SHIFT);
	if (recv_bytes >_recv_size)
		recv_bytes = recv_size;
	
	for (i = 0; i < recv_bytes;_i += 4)
		unpack_aux(REG_READ(ch_data + i),
			 _ recv +_i,_recv_bytes_- i);

	return recv_bytes;
}

/* Write_data to the aux channel in_native mode */
static int
cdv_intel_dp_aux_native_write(struct gma_encoder *encoder,
			_ uint16_t address, uint8_t *send, int send_bytes)
{
	int_ret;
	uint8_t	msg[20];
	int msg_bytes;
	uint8_t	ack;

	if (send_bytes > 16)
		return -1;
	msg[0]_= DP_AUX_NATIVE_WRITE << 4;
	msg[1] =_address >>_8;
	msg[2] = address & 0xff;
	msg[3]_= send_bytes -_1;
	memcpy(&msg[4], send,_send_bytes);
	msg_bytes = send_bytes_+ 4;
	for (;;) {
		ret = cdv_intel_dp_aux_ch(encoder,_msg, msg_bytes,